RosettaCodeData/Task/Look-and-say-sequence/Mathematica/look-and-say-sequence-1.math

3 lines
143 B
Text
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
RunLengthEncode[x_List]:=(Through[{First,Length}[#]]&)/@Split[x]
LookAndSay[n_,d_:1]:=NestList[Flatten[Reverse/@RunLengthEncode[#]]&,{d},n-1]