17 lines
494 B
Ruby
Executable File
17 lines
494 B
Ruby
Executable File
#!/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
|
|
end |