6 kyu

Range Parser

663 of 698DeepSpace

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:

  1. The input string doesn't not have to include all the token types.
  2. All integers are assumed to be positive.
  3. 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

Stats:

CreatedSep 9, 2016
PublishedSep 9, 2016
Warriors Trained1196
Total Skips30
Total Code Submissions2479
Total Times Completed698
Python Completions663
Clojure Completions31
Haskell Completions9
Total Stars37
% of votes with a positive feedback rating93% of 169
Total "Very Satisfied" Votes148
Total "Somewhat Satisfied" Votes17
Total "Not Satisfied" Votes4
Total Rank Assessments9
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • DeepSpace Avatar
  • suic Avatar
  • lilsweetcaligula Avatar
  • mauro-1 Avatar
  • tobeannouncd Avatar
Ad