RosettaCodeData/Task/McNuggets-problem/Ruby/mcnuggets-problem-2.rb

7 lines
178 B
Ruby
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
limit = 100
nugget_portions = [6, 9, 20]
arrs = nugget_portions.map{|n| 0.step(limit, n).to_a }
hits = arrs.pop.product(*arrs).map(&:sum)
p ((0..limit).to_a - hits).max # => 43