Skip to content

Instantly share code, notes, and snippets.

@pricees
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pricees/75c764008269a8386f62 to your computer and use it in GitHub Desktop.
Save pricees/75c764008269a8386f62 to your computer and use it in GitHub Desktop.
Straight forward solution to scoring a blowing game
rolls = Array.new(21, 5)
p rolls
frame = 0
scores = []
while (f = rolls.shift) # first roll
frame += 1
if f == 10 # strike!
scores << f + rolls[0].to_i + rolls[1].to_i
else
s = rolls.shift # second roll
total = f + s
if total == 10 # spare
total += rolls[0].to_i
end
scores << total
end
if frame == 10 # last frame
break
end
end
p scores
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment