OFFSET
1,1
COMMENTS
The Kolakoski sequences (A000002) can be seen as being formed from the 6-set of 3-words -> {1,1,2}, {1,2,1}, {1,2,2}, {2,1,1}, {2,1,2} and {2,2,1}. Labeling these as 1-6 gives the sequence.
The first 6 appears at a(129).
EXAMPLE
1,2,2,1,1,2 becomes 3,1
PROG
(JavaScript)
a=new Array();
a[1]=1; a[2]=2; a[3]=2; cd=1; ap=3;
for (i=4; i<1000; i++) {
if (a[ap]==1) a[i]=cd; else {a[i]=cd; a[i+1]=cd; i++}
ap++; cd=3-cd; }
for(i=1; i<300; i++) {
b=a.splice(1, 3).join();
switch (b) {
case "1, 1, 2": {document.write("1, "); break; }
case "1, 2, 1": {document.write("2, "); break; }
case "1, 2, 2": {document.write("3, "); break; }
case "2, 1, 1": {document.write("4, "); break; }
case "2, 1, 2": {document.write("5, "); break; }
case "2, 2, 1": {document.write("6, "); break; }
}
}
CROSSREFS
KEYWORD
nonn
AUTHOR
Jon Perry, Sep 11 2012
STATUS
approved