Penney's game: Difference between revisions

Content added Content deleted
(Added Kotlin)
m (→‎{{header|Perl 6}}: flatten coin flip lists)
Line 1,595: Line 1,595:


=={{header|Perl 6}}==
=={{header|Perl 6}}==
{{works with|Rakudo|2018.02}}

<lang perl6>enum Coin <Heads Tails>;
<lang perl6>enum Coin <Heads Tails>;
enum Yay <Yay Good Super Hah Ooh Yipee Sweet Cool Yes Haha>;
enum Yay <Yay Good Super Hah Ooh Yipee Sweet Cool Yes Haha>;
Line 1,629: Line 1,631:


if $flip == $mefirst {
if $flip == $mefirst {
print "{Yay.pick}! I get to choose first, and I choose: "; sleep 2; say @mine = Coin.roll(3);
print "{Yay.pick}! I get to choose first, and I choose: "; sleep 2; say @mine = |Coin.roll(3);
@yours = your-choice("Now you gotta choose: ");
@yours = your-choice("Now you gotta choose: ");
while @yours eqv @mine {
while @yours eqv @mine {
Line 1,640: Line 1,642:
@yours = your-choice("{Boo.pick}! First you choose: ");
@yours = your-choice("{Boo.pick}! First you choose: ");
say "OK, you'll win if we see: ", @yours;
say "OK, you'll win if we see: ", @yours;
print "In that case, I'll just randomly choose: "; sleep 2; say @mine = Coin(+!@yours[1]), @yours[0,1];
print "In that case, I'll just randomly choose: "; sleep 2; say @mine = Coin(+!@yours[1]), |@yours[0,1];
}
}
Line 1,662: Line 1,664:
sleep 1;
sleep 1;
print "Here we go!\n\t";
print "Here we go!\n\t";
for Coin.roll(3), &check ...^ :!defined {
for |Coin.roll(3), &check ...^ :!defined {
flipping;
flipping;
print "$_ ";
print "$_ ";