For those who are not familiarized with the Pea Pattern, it is a simple mathematical pattern.
There are multiple variations of this pattern, but we will focus in one:
Ascending Pea Pattern
It looks like this:
1 11 21 1112 3112 211213 ...
It seems really hard to get the following line, but it is really easy. The way to get the next line is by counting the number of times a digit have repeated on the previous line (start counting with the lowest, to largest):
one one one two ones one one, one two three ones, one two two ones, one two, one three ...
- We will start at
- It will be a snippet
- There must be a way to specify the number of lines generates (e.g
5will give the first 5 lines)
- The code should be as short as possible
- It must start counting from lowest to largest (the Ascending variation)