Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
23
Task/Perfect-shuffle/EasyLang/perfect-shuffle.easy
Normal file
23
Task/Perfect-shuffle/EasyLang/perfect-shuffle.easy
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
proc pshuffle . deck[] .
|
||||
mp = len deck[] / 2
|
||||
in[] = deck[]
|
||||
for i = 1 to mp
|
||||
deck[2 * i - 1] = in[i]
|
||||
deck[2 * i] = in[i + mp]
|
||||
.
|
||||
.
|
||||
proc test size . .
|
||||
for i to size
|
||||
deck0[] &= i
|
||||
.
|
||||
deck[] = deck0[]
|
||||
repeat
|
||||
pshuffle deck[]
|
||||
cnt += 1
|
||||
until deck[] = deck0[]
|
||||
.
|
||||
print cnt
|
||||
.
|
||||
for size in [ 8 24 52 100 1020 1024 10000 ]
|
||||
test size
|
||||
.
|
||||
22
Task/Perfect-shuffle/SETL/perfect-shuffle.setl
Normal file
22
Task/Perfect-shuffle/SETL/perfect-shuffle.setl
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
program faro_shuffle;
|
||||
loop for test in [8, 24, 52, 100, 1020, 1024, 10000] do
|
||||
print(lpad(str test, 5) + " cards: " + lpad(str cycle [1..test], 4));
|
||||
end loop;
|
||||
|
||||
op cycle(l);
|
||||
start := l;
|
||||
loop until l = start do
|
||||
l := shuffle l;
|
||||
n +:= 1;
|
||||
end loop;
|
||||
return n;
|
||||
end op;
|
||||
|
||||
op shuffle(l);
|
||||
return [l(mapindex(i,#l)) : i in [1..#l]];
|
||||
end op;
|
||||
|
||||
proc mapindex(i, size);
|
||||
return if odd i then i div 2+1 else (i+size) div 2 end;
|
||||
end proc;
|
||||
end program;
|
||||
Loading…
Add table
Add a link
Reference in a new issue