public
Created

Ruby golf: Rock, Paper, Scissors

  • Download Gist
rock_paper_scissors.rb
Ruby
1 2 3 4
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"))
end
# 116 chars inside

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.