Created
November 22, 2011 04:11
-
-
Save janlelis/1384869 to your computer and use it in GitHub Desktop.
ruby source golf 2011-11-21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well done!