Create a gist now

Instantly share code, notes, and snippets.

anonymous /rock_paper_scissors.rb
Created Nov 22, 2011

What would you like to do?
Ruby golf: Rock, Paper, Scissors
def play(g)
r,p,s=%w(rock paper scissors);a={r=>p,p=>s,s=>r};m=a.keys[rand(a.size)];m+','+(g==m ?"draw":(a[m]==g ?"win":"lose"))
# 116 chars inside
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment