Nilsson algorithm for the generalized Kolakoski sequence (source code)

= Nilsson algorithm for the generalized Kolakoski sequence
{c}

Here's an execution for 2, 3. When `a != 1` we use `a` as the extra numbers instead of `b`:
``
 1 | 2 2(1) ...
 2 | 2 2(0) 2(1) ...
 3 | 3 2(1) 2(0) 2(1) ...
 4 | 3 2(0) 2(0) 2(1) ...
 5 | 2 3(2) 2(1) 2(0) 2(0) ...
 6 | 2 3(1) 2(1) 2(0) 2(1) ...
 7 | 2 3(0) 2(1) 2(0) 2(1) ...
 8 | 3 3(2) 2(0) 2(0) 2(1) ...
 9 | 3 3(1) 2(0) 2(0) 2(1) ...
10 | 3 3(0) 2(0) 2(0) 2(1) ...
11 | 2 2(1) 3(2) 2(1) 2(0) 2(1) ...
12 | 2 2(0) 3(2) 2(1) 2(0) 2(1) ...
13 | 3 2(1) 3(1) 2(1) 2(0) 2(1) ...
14 | 3 2(0) 3(1) 2(1) 2(0) 2(1) ...
15 | 2 2(1) 3(0) 2(1) 2(0) 2(1) ...
16 | 2 2(0) 3(0) 2(1) 2(0) 2(1) ...
17 | 3 3(2) 3(2) 2(0) 2(0) 2(1) ...
``
Furthermore, note that if `a = 1`, then the `a, b` sequence is a subset of the `b, a` sequence e.g.:
``
1, 2 = [1, 2, 2, 1, 1, 2, 1, ...]
2, 1 = [   2, 2, 1, 1, 2, 1, ...]
``
therefore we can always make `a` not be 1 by switching the pair and then using the generalized algorithm with `a != 1`.