22 lines
394 B
Text
22 lines
394 B
Text
function lookandsay(string s)
|
|
string res = ""
|
|
integer p = s[1], c = 1
|
|
for i=2 to length(s) do
|
|
if p=s[i] then
|
|
c += 1
|
|
else
|
|
res &= sprintf("%d%s",{c,p})
|
|
p = s[i]
|
|
c = 1
|
|
end if
|
|
end for
|
|
res &= sprintf("%d%s",{c,p})
|
|
return res
|
|
end function
|
|
|
|
string s = "1"
|
|
?s
|
|
for i=1 to 10 do
|
|
s = lookandsay(s)
|
|
?s
|
|
end for
|