Skip to content

Instantly share code, notes, and snippets.

@CIAvash
Last active August 6, 2020 07:44
Show Gist options
  • Save CIAvash/ed7425d0f2d998fce6d9cac97b1ea7dc to your computer and use it in GitHub Desktop.
Save CIAvash/ed7425d0f2d998fce6d9cac97b1ea7dc to your computer and use it in GitHub Desktop.
Number guessing game in Raku
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