6 kyu
Range Parser
528 of 554DeepSpace
Description:
In this Kata you are to implement a function that parses a string which is composed from tokens of the form 'n1-n2,n3,n4-n5:n6' where 'nX' is a positive integer. Each token represent a different range:
'n1-n2' represents the range n1 to n2 (inclusive in both ends). 'n3' represents the single integer n3. 'n4-n5:n6' represents the range n4 to n5 (inclusive in both ends) but only includes every other n6 integer.
Notes:
- The input string doesn't not have to include all the token types.
- All integers are assumed to be positive.
- Tokens may be separated by
','
,', '
or,
.
Some examples:
'1-10,14, 20-25:2' -> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 20, 22, 24]
'5-10' -> [5, 6, 7, 8, 9, 10]
'2' -> [2]
The output should be a list of integers.
Algorithms
Parsing
Strings
Fundamentals
Similar Kata:
Stats:
Created | Sep 9, 2016 |
Published | Sep 9, 2016 |
Warriors Trained | 949 |
Total Skips | 21 |
Total Code Submissions | 1925 |
Total Times Completed | 554 |
Python Completions | 528 |
Clojure Completions | 29 |
Total Stars | 35 |
% of votes with a positive feedback rating | 94% of 157 |
Total "Very Satisfied" Votes | 139 |
Total "Somewhat Satisfied" Votes | 16 |
Total "Not Satisfied" Votes | 2 |
Total Rank Assessments | 9 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |