Last active
August 29, 2015 14:06
-
-
Save YusefOuda/43f0cfeebd9f5a8ad751 to your computer and use it in GitHub Desktop.
Throwing darts
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
class Darts | |
def self.score_throws(arr) | |
sum = 0 | |
flag = true | |
arr.each do |dart| | |
if dart < 5 | |
sum += 10 | |
elsif dart <= 10 | |
sum += 5 | |
else | |
flag = false | |
end | |
end | |
sum += 100 if flag && arr.size > 0 | |
sum | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment