Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
17
Task/Nim-game/Perl/nim-game.pl
Normal file
17
Task/Nim-game/Perl/nim-game.pl
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use feature 'say';
|
||||
|
||||
my $tokens = 12;
|
||||
say "$tokens tokens remaining.\n";
|
||||
|
||||
while (1) {
|
||||
print "How many tokens do you want to remove; 1, 2 or 3? : ";
|
||||
(my $player = <>) =~ s/\s//g;
|
||||
say "Nice try. $tokens tokens remaining.\n" and next
|
||||
unless $player =~ /^[123]$/;
|
||||
$tokens -= 4;
|
||||
say "Computer takes @{[4 - $player]}.\n$tokens tokens remaining.\n";
|
||||
say "Computer wins." and last
|
||||
if $tokens <= 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue