Inspired by Using LaTeX to compact a list of numbers, this challenge is to output a compact list of numbers, given a range, as follows:
Input: 1,2, 3,4,5,8,11, 12,13 Output: 1-5, 8, 11-13 Input: 20,21,45,56,75, 76,77,78 Output: 20-21, 45, 56, 75-78 Input: 4,5 Output: 4-5
Input is always comma separated numbers, sometimes with spacing, and output should be in the format above -- note space after the commas. There is no upper limit to the length of the input string.
Winner: Smallest in terms of bytes