Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chomp ( $input = <STDIN>);
- if ( $input =~ /stones=([^&]+)/ ) { $stones = $1 }
- $random= int(rand(20)) + 10;
- if ( $input =~ /re=/ ) { $stones = $rnd; }
- if ( $input =~ /take1=([^&]+)/ ) { $stones -= 1; }
- if ( $input =~ /take2=([^&]+)/ ) { $stones -= 2; }
- if ($stones < 0 ) { $stones = 0; }
- if( $input eq "" ) { $stones = $random; }
- print "<h1>Roy's Nim</h1>";
- print "<h2>There are $stones stones.</h2>\n";
- print "<form method='post' action=''>\n";
- print "<input type='hidden' value='$stones' name='stones'>\n";
- if ( $stones > 0 ) {
- print "<input type='submit' name='take1' value='Take 1'><br><br>";
- if( $stones >= 2 ){ print "<input type='submit' name='take2' value='Take 2'><br><br>"; }
- } else {
- print "<h2>You won</h2>";
- }
- print "<input type='submit' name='re' value='Start Over'> ";
- print "</form>\n";
- print "</html>\n";
Add Comment
Please, Sign In to add comment