public
Created

ruby source golf 2011-11-21

  • Download Gist
hole4.rb
Ruby
1 2 3 4 5 6 7 8
# hole 3 in 93 bytes (only counting newlines between method body)
# see http://rubysource.com/ruby-golf/
 
def play(i)
s=%w[Rock Paper Scissors]
p=s.index i
s[c=rand(3)]+",#{p==c ?:Draw: p&&p==-~c%3?:Win: :Lose}"
end
hole4_2.rb
Ruby
1 2 3 4 5 6 7 8
# hole 3 in 84 bytes (only counting newlines between method body)
# see http://rubysource.com/ruby-golf/
# based on https://gist.github.com/1385465
 
def play(i)
m=%w(Rock Paper Scissors)
m[c=rand(3)]+?,+%w(Draw Win Lose)[((m.index(i)||c-1)-c)%3]
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.