Last active
August 6, 2020 07:44
-
-
Save CIAvash/ed7425d0f2d998fce6d9cac97b1ea7dc to your computer and use it in GitHub Desktop.
Number guessing game in Raku
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
put 'Guess the number!'; | |
my Int:D $secret_number := (1..100).pick; | |
loop { | |
with +prompt "Please input your guess.\n" { | |
when UInt:D { | |
put "You guessed: $_"; | |
given $_ <=> $secret_number { | |
when More { put 'Too big!' } | |
when Less { put 'Too small!' } | |
when Same { put 'You win!'; last } | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment