Data update
This commit is contained in:
parent
52a6ef48dd
commit
157b70a810
604 changed files with 14253 additions and 2100 deletions
|
|
@ -0,0 +1,37 @@
|
|||
BEGIN # subtractive generator - translated from the C/EasyLang samples #
|
||||
INT modulus = 1 000 000 000;
|
||||
INT max state = 55;
|
||||
[ 0 : max state - 1 ]INT state;
|
||||
INT sgi := 0, sgj := 0;
|
||||
|
||||
PROC subrand seed = ( INT p1in )VOID: BEGIN
|
||||
INT p1 := p1in, p2 := 1;
|
||||
state[ 0 ] := p1 MOD modulus;
|
||||
INT j := 21; # not sure how 21 is chosen, though it is coprime to max state #
|
||||
TO max state - 1 DO
|
||||
state[ j ] := p2;
|
||||
p2 := ( p1 - p2 ) MOD modulus;
|
||||
p1 := state[ j ];
|
||||
j +:= 21 MODAB max state
|
||||
OD;
|
||||
sgi := 0;
|
||||
sgj := 24; # the task states this value (24) should be coprime to max state #
|
||||
FROM 0 TO ( 3 * max state ) - 1 DO
|
||||
VOID( subrand )
|
||||
OD
|
||||
END;
|
||||
|
||||
PROC subrand = INT: BEGIN
|
||||
IF sgi = sgj THEN
|
||||
subrand seed( 0 )
|
||||
FI;
|
||||
sgi -:= 1 MODAB max state;
|
||||
sgj -:= 1 MODAB max state;
|
||||
state[ sgi ] -:= state[ sgj ] MODAB modulus
|
||||
END;
|
||||
|
||||
subrand seed( 292929 );
|
||||
TO 10 DO
|
||||
print( ( whole( subrand, 0 ), newline ) )
|
||||
OD
|
||||
END
|
||||
41
Task/Subtractive-generator/XPL0/subtractive-generator.xpl0
Normal file
41
Task/Subtractive-generator/XPL0/subtractive-generator.xpl0
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
define MOD = 1_000_000_000;
|
||||
int State(55), SI, SJ;
|
||||
|
||||
ffunc Subrand;
|
||||
|
||||
proc SubrandSeed(P1);
|
||||
int P1;
|
||||
int P2, I, J;
|
||||
[P2:= 1;
|
||||
State(0):= rem(P1 / MOD);
|
||||
J:= 21;
|
||||
for I:= 1 to 55-1 do
|
||||
[if J >= 55 then J:= J - 55;
|
||||
State(J):= P2;
|
||||
P2:= P1 - P2;
|
||||
if P2 < 0 then P2:= P2 + MOD;
|
||||
P1:= State(J);
|
||||
J:= J + 21;
|
||||
];
|
||||
SI:= 0;
|
||||
SJ:= 24;
|
||||
for I:= 0 to 165-1 do Subrand;
|
||||
];
|
||||
|
||||
func Subrand;
|
||||
int X;
|
||||
[if SI = SJ then SubrandSeed(0);
|
||||
SI:= if SI then SI-1 else 54;
|
||||
SJ:= if SJ then SJ-1 else 54;
|
||||
X:= State(SI) - State(SJ);
|
||||
if X < 0 then X:= X + MOD;
|
||||
State(SI):= X;
|
||||
return X;
|
||||
];
|
||||
|
||||
int I;
|
||||
[SI:= 0; SJ:= 0;
|
||||
SubrandSeed(292929);
|
||||
for I:= 0 to 10-1 do
|
||||
[IntOut(0, Subrand); CrLf(0)];
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue