forked from code-clash/look-and-say
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rohweini d49e0b9453 | 4 years ago | |
---|---|---|
.idea | 4 years ago | |
gradle/wrapper | 4 years ago | |
src | 4 years ago | |
.gitignore | 4 years ago | |
README.md | 4 years ago | |
build.gradle | 4 years ago | |
gradlew | 4 years ago | |
gradlew.bat | 4 years ago | |
settings.gradle | 4 years ago |
README.md
Look-and-Say
Goal
Given an iteration-count
generate and output the look-and-say
sequence.
The sequence starts with 1
. Subsequent numbers are derived by describing the previous number in terms of consecutive digits.
To generate an entry of the sequence, examine the previous entry.
Read off the digits of the previous entry, counting the number of digits in groups of the same digit.
In human terms this is like speaking out loud how often each digit appears consecutively.
Keep in mind: the output becomes very long very quickly.
Input
iterations
- a numeric value how often the process is repeated
Output
The head of the generated sequence after iterating by the given input.
Constraints
- 0 <=
iterations
<= 28 - Start value = 1
Examples
- for input
0
iterations, output1
, i.e. the starting value) - for input
1
iterations, output11
, i.e. reading the previous entry1
asone 1
- for input
2
iterations, output21
, i.e. reading the previous entry11
astwo 1s
- for input
3
iterations, output1211
, i.e. reading the previous entry21
asone 2 one 1
- for input
4
iterations, output111221
, i.e. reading the previous entry1211
asone 1 one 2 two 1