OFFSET
1,4
COMMENTS
LINKS
Reinhard Zumkeller, Rows n = 1..25 of triangle, flattened
J. H. Conway, The weird and wonderful chemistry of audioactive decay, in T. M. Cover and Gopinath, eds., Open Problems in Communication and Computation, Springer, NY 1987, pp. 173-188. DOI: 10.1007/978-1-4612-4808-8_53.
M. Lothaire, Algebraic Combinatorics on Words, Cambridge, 2002, see p. 36.
Kevin Watkins, Proving Conway's Lost Cosmological Theorem, POP seminar talk, CMU, Dec 2006.
Eric Weisstein's World of Mathematics, Look and Say Sequence
Wikipedia, Look-and-say sequence
EXAMPLE
. Initial rows A005150
. 1: 1 1
. 2: 1,1 11
. 3: 2,1 21
. 4: 1,2,1,1 1211
. 5: 1,1,1,2,2,1 111221
. 6: 3,1,2,2,1,1 312211
. 7: 1,3,1,1,2,2,2,1 13112221
. 8: 1,1,1,3,2,1,3,2,1,1 1113213211
. 9: 3,1,1,3,1,2,1,1,1,3,1,2,2,1 31131211131221
-}
PROG
(Haskell) see Watkins link, p. 3.
import Data.List (group)
a034002 n k = a034002_tabf !! (n-1) !! (k-1)
a034002_row n = a034002_tabf !! (n-1)
a034002_tabf = iterate
(concat . map (\xs -> [length xs, head xs]) . group) [1]
-- Reinhard Zumkeller, Aug 09 2012
(Python)
from sympy import flatten
l=[1]
L=[1]
n=s=1
y=''
while n<21:
x=str(l[n - 1]) + ' '
for i in range(len(x) - 1):
if x[i]==x[i + 1]: s+=1
else:
y+=str(s)+str(x[i])
s=1
x=''
n+=1
l.append(int(y))
L.append([int(a) for a in list(y)])
y=''
s=1
print(l) # A005150
print(flatten(L)) # Indranil Ghosh, Jul 05 2017
CROSSREFS
KEYWORD
nonn,base,tabf
AUTHOR
EXTENSIONS
Offset changed and keyword tabf added by Reinhard Zumkeller, Aug 09 2012
STATUS
approved