Managing ranges with LINQ challenge
问题 Given the following numbers (representing days of week): 1,2,3,4,5,6,7 . Here are some combination examples and their desired output: 1,2,3,5,6,7 -> 1-3,5-7 1,3,5,7 -> 1,3,5,7 1,2,5,6 -> 1,2,5,6 1,2,3,6,7 -> 1-3,6,7 The idea is that 3 or more consecutive days become a range while single or non-following days are rendered separately (or is it nicer to make range starting from 2). I don't know where to start should I write a complicated if ed function or this can be done with one of the LINQ