Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,63 @@
|
|||
figfig = cluster is ffr, ffs
|
||||
rep = null
|
||||
ai = array[int]
|
||||
own R: ai := ai$[1]
|
||||
own S: ai := ai$[2]
|
||||
|
||||
% Extend R and S until R(n) is known
|
||||
extend = proc (n: int)
|
||||
while n > ai$high(R) do
|
||||
next: int := ai$top(R) + S[ai$high(R)]
|
||||
ai$addh(R, next)
|
||||
while ai$top(S) < next-1 do
|
||||
ai$addh(S, ai$top(S)+1)
|
||||
end
|
||||
ai$addh(S, next+1)
|
||||
end
|
||||
end extend
|
||||
|
||||
ffr = proc (n: int) returns (int)
|
||||
extend(n)
|
||||
return(R[n])
|
||||
end ffr
|
||||
|
||||
ffs = proc (n: int) returns (int)
|
||||
while n > ai$high(S) do
|
||||
extend(ai$high(R) + 1)
|
||||
end
|
||||
return(S[n])
|
||||
end ffs
|
||||
end figfig
|
||||
|
||||
start_up = proc ()
|
||||
ai = array[int]
|
||||
po: stream := stream$primary_output()
|
||||
|
||||
% Print R[1..10]
|
||||
stream$puts(po, "R[1..10] =")
|
||||
for i: int in int$from_to(1,10) do
|
||||
stream$puts(po, " " || int$unparse(figfig$ffr(i)))
|
||||
end
|
||||
stream$putl(po, "")
|
||||
|
||||
% Count the occurrences of 1..1000 in R[1..40] and S[1..960]
|
||||
occur: ai := ai$fill(1, 1000, 0)
|
||||
for i: int in int$from_to(1, 40) do
|
||||
occur[figfig$ffr(i)] := occur[figfig$ffr(i)] + 1
|
||||
end
|
||||
for i: int in int$from_to(1, 960) do
|
||||
occur[figfig$ffs(i)] := occur[figfig$ffs(i)] + 1
|
||||
end
|
||||
|
||||
% See if they all occur exactly once
|
||||
begin
|
||||
for i: int in int$from_to(1, 1000) do
|
||||
if occur[i] ~= 1 then exit wrong(i) end
|
||||
end
|
||||
stream$putl(po,
|
||||
"All numbers 1..1000 occur exactly once in R[1..40] U S[1..960].")
|
||||
end except when wrong(i: int):
|
||||
stream$putl(po, "Error: " ||
|
||||
int$unparse(i) || " occurs " || int$unparse(occur[i]) || " times.")
|
||||
end
|
||||
end start_up
|
||||
Loading…
Add table
Add a link
Reference in a new issue