Gavin Grundlingh on Nostr: So I'm sitting with an interesting coding problem to solve. I have the following list ...
So I'm sitting with an interesting coding problem to solve. I have the following list of numbers:
1, 2, 3, 5, 6, 10, 12, 13, 14, 15
These numbers represent the channels that are enabled on a Reaper track. I would like to report this in ranges according to the following rules:
1. If there is only one number in the range, just add it to the list of enabled channels.
2. If there are two consecutive numbers in the range, add "X and Y" to the list.
3. If there are three or more consecutive numbers in the range, add "X to Y" to the list.
So, using the list of numbers above, my report should look like this:
1 to 3, 5 and 6, 10, 12 to 15
Is there any way of doing this?
1, 2, 3, 5, 6, 10, 12, 13, 14, 15
These numbers represent the channels that are enabled on a Reaper track. I would like to report this in ranges according to the following rules:
1. If there is only one number in the range, just add it to the list of enabled channels.
2. If there are two consecutive numbers in the range, add "X and Y" to the list.
3. If there are three or more consecutive numbers in the range, add "X to Y" to the list.
So, using the list of numbers above, my report should look like this:
1 to 3, 5 and 6, 10, 12 to 15
Is there any way of doing this?