initial solution for second challenge

master
Jeff Yates 2020-12-02 10:47:05 -05:00
parent 39c3269366
commit c72dfaa5e7
1 changed files with 16 additions and 0 deletions

16
day01/solution2.rb Normal file
View File

@ -0,0 +1,16 @@
#!/bin/env ruby
#Find the three entries that sum to 2020; what do you get if you multiply them together?
numbers = File.readlines('./input')
numbers.map! { |s| s.to_i}
numbers.each do |num1|
numbers.each do |num2|
numbers.each do |num3|
sum = num1 + num2 + num3
puts num1.to_s + '+' + num2.to_s + '+' + num3.to_s + '=' + sum.to_s
if sum == 2020
puts num1 * num2 * num3
exit
end
end
end