Kolakoski

2219 days ago by calkin

def kol(S): alph=[1,2] new_list=[] current_symbol=1 for i in S: new_list.append(current_symbol) if i==2: new_list.append(current_symbol) current_symbol=3-current_symbol return(new_list) 
       
a=kol([1,2]) 
       
a=kol([1,2]) new_length=Integer(len(a)) for i in range(3,35): old_length=new_length #print type(old_length),new_length a=kol(a) new_length=Integer(len(a)) #print old_length,new_length print(i, (new_length/old_length).n()) 
       
(3, 1.66666666666667)
(4, 1.40000000000000)
(5, 1.42857142857143)
(6, 1.50000000000000)
(7, 1.53333333333333)
(8, 1.47826086956522)
(9, 1.47058823529412)
(10, 1.50000000000000)
(11, 1.50666666666667)
(12, 1.50442477876106)
(13, 1.50000000000000)
(14, 1.49803921568627)
(15, 1.50261780104712)
(16, 1.50348432055749)
(17, 1.49826187717265)
(18, 1.49806651198763)
(19, 1.49870934434693)
(20, 1.49948329314502)
(21, 1.49919595681139)
(22, 1.50000000000000)
(23, 1.50045969966289)
(24, 1.49979575163399)
(25, 1.50034046030233)
(26, 1.50001512813531)
(27, 1.50027230368921)
(28, 1.50015461353339)
(29, 1.50016131923284)
(30, 1.50004779315124)
(31, 1.49998406945717)
(32, 1.49996150077928)
(33, 1.49996105725999)
(34, 1.49999409943166)
(3, 1.66666666666667)
(4, 1.40000000000000)
(5, 1.42857142857143)
(6, 1.50000000000000)
(7, 1.53333333333333)
(8, 1.47826086956522)
(9, 1.47058823529412)
(10, 1.50000000000000)
(11, 1.50666666666667)
(12, 1.50442477876106)
(13, 1.50000000000000)
(14, 1.49803921568627)
(15, 1.50261780104712)
(16, 1.50348432055749)
(17, 1.49826187717265)
(18, 1.49806651198763)
(19, 1.49870934434693)
(20, 1.49948329314502)
(21, 1.49919595681139)
(22, 1.50000000000000)
(23, 1.50045969966289)
(24, 1.49979575163399)
(25, 1.50034046030233)
(26, 1.50001512813531)
(27, 1.50027230368921)
(28, 1.50015461353339)
(29, 1.50016131923284)
(30, 1.50004779315124)
(31, 1.49998406945717)
(32, 1.49996150077928)
(33, 1.49996105725999)
(34, 1.49999409943166)
len(a) 
       
1271059
1271059
a[:10] 
       
[1, 2, 2, 1, 1, 2, 1, 2, 2, 1]
[1, 2, 2, 1, 1, 2, 1, 2, 2, 1]