Jump to content

Look-and-say sequence: Difference between revisions

Line 3,681:
 
?></lang>
 
=={{header|Picat}}==
<lang Picat>go =>
S1 = "1",
foreach(_ in 1..11)
println(S1),
S1 := runs(S1)
end,
println(S1),
nl.
 
runs(X) = V =>
S = "",
Last = X[1],
C = 1,
foreach(I in 2..X.length)
if X[I] == Last then
C := C + 1
else
S := S ++ C.to_string() ++ [X[I-1]],
C := 1,
Last := X[I]
end
end,
V = S ++ C.to_string() ++ [Last].</lang>
 
Output:
<pre>1
11
21
1211
111221
312211
13112221
1113213211
31131211131221
13211311123113112211
11131221133112132113212221
3113112221232112111312211312113211</pre>
 
 
=={{header|PicoLisp}}==
495

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.