Given a string of unsorted alphanumeric characters, e.g.
ABC321STPpJqZZr0
output a ", "-separated list of character ranges, sorted by ASCII value, ignoring case and removing duplicates (i.e. outputting only uppercase and numeric characters), e.g.
0-3, A-C, J, P-T, Z
Rules
- Any language currently supported by Ideone.com, or GolfScript—if you're okay with cheating :-)
- The length of your program is your base score, as usual.
- You must initialize (hardcode) the above example within your program, but you may discount the length of that example from your program length, e.g. for
char* s="ABC321STPpJqZZr0";
you may discount 16 chars, the other 11 chars counting toward your program length.
Bonus (+50 bounty)
- As this was a real problem encountered by my coworker today, needing to be written in Tcl 8.0.5 (an ancient version, lacking many of the latest Tcl built-ins), I'll award 50 points to whomever writes the shortest Tcl 8.0.5 solution, if there are at least 2 valid submissions in Tcl 8.0.5.