We all already crossed the look and say sequence, and where asked to guess the next element. As its name tells it very well, you just have to say what you see :
1
1 1
2 1
1 2 1 1
1 1 1 2 2 1
3 1 2 2 1 1
...
But, what if we had to use a different base to describe it? You could count it in base 3 as this OEIS squence do. You could even do it in whatever base you want! That will be your job in this challenge.
Goal
Your have to write a program or a function that will accept two integers as input, either by STDIN or as function arguments. The first one will be the base b
you have to work in, the second one will be the number n
of elements to output. As this sequence never changes for b>=4
, you will assume 0<b<5
.
The only restriction you have is to NOT use any base-converison built-in :).
The original sequence (in base 10) is the sequence A005150. It cannot be constructed simply by using a formula, so you can help yourself with the different implementations present on the sequence's page.
Sample output
Here are the first 10 elements for each b
for b=1:
1
11
111
1111
11111
111111
1111111
11111111
111111111
1111111111
for b=2:
1
11
101
111011
11110101
100110111011
111001011011110101
111100111010110100110111011
100110011110111010110111001011011110101
1110010110010011011110111010110111100111010110100110111011
for b=3:
1
11
21
1211
111221
1012211
1110112221
101102110211
111021101221101221
1011012211011222110112211
for b=4:
1
11
21
1211
111221
312211
13112211
1113212221
311312113211
132113111221131221
You can use whatever formating you want as long it is readable (so you could output it in Python-like lists, separated by commas/newline...).
This is code-golf, so the shortest code in byte wins. Have fun !