secret
Created

rps

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.