Last active
April 16, 2016 05:06
-
-
Save kunitoo/5dbefafcc4dff76d4657881141c3c79c to your computer and use it in GitHub Desktop.
Toyama.rb #05 問題1
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
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