Look-and-say sequence: Difference between revisions
Content deleted Content added
Not a robot (talk | contribs) Add ABC |
|||
Line 221: | Line 221: | ||
newline: db 13,10,'$' ; Newline to print in between members |
newline: db 13,10,'$' ; Newline to print in between members |
||
memb: db '1$' ; This is where the current member is stored</syntaxhighlight> |
memb: db '1$' ; This is where the current member is stored</syntaxhighlight> |
||
=={{header|ABC}}== |
|||
<syntaxhighlight lang="abc">HOW TO RETURN look.and.say seq: |
|||
PUT "" IN result |
|||
PUT 0 IN n |
|||
PUT "" IN c |
|||
FOR ch IN seq: |
|||
SELECT: |
|||
c=ch: |
|||
PUT n+1 IN n |
|||
ELSE: |
|||
IF n>0: PUT result^"`n`"^c IN result |
|||
PUT 1 IN n |
|||
PUT ch IN c |
|||
RETURN result^"`n`"^c |
|||
PUT "1" IN item |
|||
FOR i IN {1..14}: |
|||
WRITE item/ |
|||
PUT look.and.say item IN item</syntaxhighlight> |
|||
{{out}} |
|||
<pre>1 |
|||
11 |
|||
21 |
|||
1211 |
|||
111221 |
|||
312211 |
|||
13112221 |
|||
1113213211 |
|||
31131211131221 |
|||
13211311123113112211 |
|||
11131221133112132113212221 |
|||
3113112221232112111312211312113211 |
|||
1321132132111213122112311311222113111221131221 |
|||
11131221131211131231121113112221121321132132211331222113112211</pre> |
|||