6 kyu

Slices of a Series of Digits

313 of 417noku

Description:

Write a program that will take a string of digits and give you all the possible consecutive slices of length n in that string.

Raise an error if n is larger than the length of the string.

Examples

For example, the string "01234" has the following 2-digit slices:

[0, 1], [1, 2], [2, 3], [3, 4]

The same string has the following 4-digit slices:

[0, 1, 2, 3], [1, 2, 3, 4]
Algorithms
Data Structures

More By Author:

Check out these other kata created by noku

Stats:

CreatedAug 24, 2014
PublishedAug 24, 2014
Warriors Trained689
Total Skips21
Total Code Submissions1884
Total Times Completed417
Ruby Completions117
Python Completions313
Total Stars7
% of votes with a positive feedback rating88% of 136
Total "Very Satisfied" Votes110
Total "Somewhat Satisfied" Votes19
Total "Not Satisfied" Votes7
Total Rank Assessments41
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • noku Avatar
  • JoshBrodieNZ Avatar
  • NaMe613 Avatar
  • anter69 Avatar
  • daniloxxv Avatar
  • saudiGuy Avatar
Ad