Skip to content

Instantly share code, notes, and snippets.

@kristenmills
Created June 8, 2012 00:20
Show Gist options
  • Save kristenmills/2892581 to your computer and use it in GitHub Desktop.
Save kristenmills/2892581 to your computer and use it in GitHub Desktop.
Project Euler 31
def solve
coins = [1, 2, 5, 10, 20, 50, 100, 200]
goal = 200
ways = Array.new
ways << 1
200.times do
ways << 0
end
coins.each do |coin|
coin.upto(goal) do |x|
ways[x] += ways[x-coin]
end
end
return ways[goal]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment