September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
20
Task/Permutation-test/Phix/permutation-test.phix
Normal file
20
Task/Permutation-test/Phix/permutation-test.phix
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
constant data = {85, 88, 75, 66, 25, 29, 83, 39, 97,
|
||||
68, 41, 10, 49, 16, 65, 32, 92, 28, 98 }
|
||||
|
||||
function pick(int at, int remain, int accu, int treat)
|
||||
if remain=0 then return iff(accu>treat?1:0) end if
|
||||
return pick(at-1, remain-1, accu+data[at], treat) +
|
||||
iff(at>remain?pick(at-1, remain, accu, treat):0)
|
||||
end function
|
||||
|
||||
int treat = 0, le, gt
|
||||
atom total = 1;
|
||||
for i=1 to 9 do treat += data[i] end for
|
||||
for i=19 to 11 by -1 do total *= i end for
|
||||
for i=9 to 1 by -1 do total /= i end for
|
||||
|
||||
gt = pick(19, 9, 0, treat)
|
||||
le = total - gt;
|
||||
|
||||
printf(1,"<= : %f%% %d\n > : %f%% %d\n",
|
||||
{100*le/total, le, 100*gt/total, gt})
|
||||
Loading…
Add table
Add a link
Reference in a new issue