Navigation Icon

Input

Description

This application returns a list of integers generated from special range expressions using a simple syntax. Ranges [-] can be ascending or descending, stepped [*] or staggered [%]. Unique numbers are treated as expressions. Each expression can also be negated [!].

In addition to expanding expressions, the resulting expansion can be collapsed back to an expression(s). Choose 'collapse' and enter a comma separated list of integers.

The algorithm can be run server-side using Python or client-side using JavaScript.

Example 1 - Ascending
1-20
...
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
Example 2 - Descending
20-1
...
[20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
Example 3 - Stepped
1-20x3
...
[1, 4, 7, 10, 13, 16, 19]
Example 4 - Staggered
1-20%3
...
[1, 4, 7, 10, 13, 16, 19, 2, 5, 8, 11, 14, 17, 20, 3, 6, 9, 12, 15, 18]
Example 5 - Complex
1-20%3 !2-16x2 40-30 !35
...
[1, 7, 13, 19, 5, 11, 17, 20, 3, 9, 15, 18, 40, 39, 38, 37, 36, 34, 33, 32, 31, 30]
Example 6 - Collapsed
1, 7, 13, 19, 5, 11, 17, 20, 3, 9, 15, 18, 40, 39, 38, 37, 36, 34, 33, 32, 31, 30
...
['1-15*2', '17-20', '30-34', '36-40']