I have a list of number. That list may be in series or without series. So we need output in following manner.
- if elements are in continuous series then we need to write start-last e.g. 8,9,10,11 then output would be 8-11.
- if any set of number is not in series then we need to write same value e.g. 1,3,4,5,7,8 then output would be 1,3-5,7,8. Here 1,3 (2 is missing in between) so it will display as 1,3 then follow rule 1.
- if only 2 elements are in series like 1,2 or 2,3 then no need to write 1-2 or 2-3. just same(1,2 or 2,3) is fine.
below is example of all rules.
8,9,10,11 = 8-11
1,2,3,5,7,8,10,11,12,14 = 1-3,5,7,8,10-12,14
1,3,4,5,7,8 = 1,3-5,7,8
1,3,4,5,7,8,9,10 = 1,3-5,7-10