Problem 1 - List Compression
Introduction
This problem involves replacing runs of three or more consecutive
numbers with an equivalent range.
Input
The input will consist of zero or more integers, one per line with no extra
spaces at the beginning or end of the line. The numbers will be in
strictly increasing order.
Output
The output must consist of a comma-separated list of individual
numbers and ranges in strictly increasing order. The first and last numbers in
a range should be separated by a colon (':'). Ranges should only
be used for runs of three or more consecutive numbers. If a number is
present in the input then it must either be present in the output explictly
as an individual number or endpoint of a range, or implicitly
by being between the endpoints of a range. No other numbers should
be listed in the output either explicitly or implicitly. There should
be a single end-of-line at the end of the output but no other whitespace.
Example
Input:
1
2
3
5
Output:
1:3,5