33 lines
635 B
Text
33 lines
635 B
Text
include "cowgol.coh";
|
|
|
|
sub print_list(ptr: [uint16], n: uint8) is
|
|
while n > 0 loop
|
|
print_i16([ptr]);
|
|
print_char(' ');
|
|
n := n - 1;
|
|
ptr := @next ptr;
|
|
end loop;
|
|
print_nl();
|
|
end sub;
|
|
|
|
const LIMIT := 1000;
|
|
var eck: uint16[LIMIT];
|
|
MemZero(&eck as [uint8], @bytesof eck);
|
|
var i: @indexof eck;
|
|
var j: @indexof eck;
|
|
|
|
i := 0;
|
|
while i < LIMIT-1 loop
|
|
j := i-1;
|
|
while j != -1 loop
|
|
if eck[i] == eck[j] then
|
|
eck[i+1] := i-j;
|
|
break;
|
|
end if;
|
|
j := j - 1;
|
|
end loop;
|
|
i := i + 1;
|
|
end loop;
|
|
|
|
print_list(&eck[0], 10);
|
|
print_list(&eck[LIMIT-10], 10);
|