Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Penneys-game/Zkl/penneys-game.zkl
Normal file
18
Task/Penneys-game/Zkl/penneys-game.zkl
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
fcn coinToss{ (0).random(2) and "H" or "T" } // (0).random(2) --> 0<=r<2
|
||||
reg myBet, yourBet;
|
||||
if(coinToss()=="H"){ // The toss says I go first
|
||||
myBet=(3).pump(String,coinToss);
|
||||
println("I bet ",myBet);
|
||||
yourBet=ask("Your bet of three (H/T): ")[0,3].toUpper();
|
||||
}else{
|
||||
yourBet=ask("Your bet of three (H/T): ")[0,3].toUpper();
|
||||
myBet=((yourBet[1]=="H") and "T" or "H") + yourBet[0,2];
|
||||
println("I bet ",myBet);
|
||||
}
|
||||
print("Flipping: "); coins:="";
|
||||
while(1){
|
||||
print(toss:=coinToss()); coins=coins + toss;
|
||||
if(Void!=coins.find(yourBet)){ println(" You win!"); break; }
|
||||
if(Void!=coins.find(myBet)) { println(" I win!"); break; }
|
||||
// ignore we both won
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue