Skip to content

Instantly share code, notes, and snippets.

@smoil
Created November 22, 2011 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smoil/c3ec22ca4fc84104f17c to your computer and use it in GitHub Desktop.
Save smoil/c3ec22ca4fc84104f17c to your computer and use it in GitHub Desktop.
rps
def play(s)
m,q=rand(3),%w(Rock Scissors Paper)
i=q.index(s)
return "#{q[m]},Draw" if m == i
return "#{q[m]},Win" if i&&i != (m+1)%3
return "#{q[m]},Lose"
end
def play(s)
m,q=rand(3),%w(Rock Scissors Paper);i=q.index s;q[m]+?,+(m==i ? "Draw":i&&i!=(m+1)%3?"Win":"Lose")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment