Look-and-say sequence: Difference between revisions
Content added Content deleted
(Added XPL0 example.) |
|||
Line 5,544: | Line 5,544: | ||
}</syntaxhighlight> |
}</syntaxhighlight> |
||
{{out}} |
|||
<pre> |
|||
1 |
|||
11 |
|||
21 |
|||
1211 |
|||
111221 |
|||
312211 |
|||
13112221 |
|||
1113213211 |
|||
31131211131221 |
|||
13211311123113112211 |
|||
11131221133112132113212221 |
|||
3113112221232112111312211312113211 |
|||
1321132132111213122112311311222113111221131221 |
|||
11131221131211131231121113112221121321132132211331222113112211 |
|||
311311222113111231131112132112311321322112111312211312111322212311322113212221 |
|||
</pre> |
|||
=={{header|XPL0}}== |
|||
<syntaxhighlight lang "XPL0">char Seq0(100), Seq1(100); |
|||
int Iter, Digit, Count, I0, I1, T; |
|||
string 0; |
|||
[Seq0(0):= ^1; Seq0(1):= 0; |
|||
Text(0, Seq0); CrLf(0); |
|||
for Iter:= 2 to 15 do |
|||
[I1:= 0; I0:= 0; |
|||
repeat Digit:= Seq0(I0); |
|||
Count:= ^1; |
|||
I0:= I0+1; |
|||
while Seq0(I0) = Digit do |
|||
[Count:= Count+1; |
|||
I0:= I0+1; |
|||
]; |
|||
Seq1(I1):= Count; I1:= I1+1; |
|||
Seq1(I1):= Digit; I1:= I1+1; |
|||
until Seq0(I0) = 0; |
|||
Seq1(I1):= 0; |
|||
T:= Seq0; Seq0:= Seq1; Seq1:= T; |
|||
Text(0, Seq0); CrLf(0); |
|||
]; |
|||
]</syntaxhighlight> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |