Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
15
Task/Monty-Hall-problem/Phix/monty-hall-problem.phix
Normal file
15
Task/Monty-Hall-problem/Phix/monty-hall-problem.phix
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
integer swapWins = 0, stayWins = 0, winner, choice, reveal, other
|
||||
atom t0 = time()
|
||||
|
||||
for game=1 to 1_000_000 do
|
||||
winner = rand(3)
|
||||
choice = rand(3)
|
||||
while 1 do
|
||||
reveal = rand(3)
|
||||
if reveal!=winner and reveal!=choice then exit end if
|
||||
end while
|
||||
stayWins += (choice==winner)
|
||||
other = 6-choice-reveal -- (as 1+2+3=6, and reveal!=choice)
|
||||
swapWins += (other==winner)
|
||||
end for
|
||||
printf(1, "Stay: %,d\nSwap: %,d\nTime: %3.2fs\n",{stayWins,swapWins,time()-t0})
|
||||
Loading…
Add table
Add a link
Reference in a new issue