Skip to content

Instantly share code, notes, and snippets.

@kunitoo
Last active April 16, 2016 05:06
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 kunitoo/5dbefafcc4dff76d4657881141c3c79c to your computer and use it in GitHub Desktop.
Save kunitoo/5dbefafcc4dff76d4657881141c3c79c to your computer and use it in GitHub Desktop.
Toyama.rb #05 問題1
module Q1
def self.count
coins = [10, 50, 100, 500]
result = []
(2..15).each do |n|
coins.repeated_combination(n).each do |cs|
result << cs if cs.inject(:+) == 1000
end
end
result.count
end
end
puts "answer : #{Q1.count}" #=> answer : 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment