Skip to content

Instantly share code, notes, and snippets.

@FredrikAugust
Last active February 17, 2017 14:28
Show Gist options
  • Save FredrikAugust/9a8a4be5ddd81a9133d35732ac21d199 to your computer and use it in GitHub Desktop.
Save FredrikAugust/9a8a4be5ddd81a9133d35732ac21d199 to your computer and use it in GitHub Desktop.
Rock paper scissor in ruby, 232 bytes
p 'Would you like to play a game?'
abort 'I hope to play sometime' unless gets.chomp.upcase.ord==89
p 'Rock, paper or scissors?'
p (s=(a={82=>83,80=>82,83=>80}).keys.sample)==(i=gets.upcase.ord) ? 'Tie' : (a[i]==s ? 'Win' : 'Loss')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment