AoC2020/day01/solution1.rb

14 lines
388 B
Ruby
Raw Normal View History

2020-12-02 15:19:07 +00:00
#!/bin/env ruby
#Find the two entries that sum to 2020; what do you get if you multiply them together?
2020-12-02 15:23:24 +00:00
numbers = File.readlines('./input')
2020-12-02 15:19:07 +00:00
numbers.each do |num1|
numbers.each do |num2|
2020-12-02 15:27:44 +00:00
sum = num1.to_i + num2.to_i
2020-12-02 15:29:36 +00:00
puts num1.strip + '+' + num2.strip + '=' + sum.to_s
2020-12-02 15:19:07 +00:00
if sum == 2020
2020-12-02 15:27:44 +00:00
puts num1.to_i * num2.to_i
2020-12-02 15:19:07 +00:00
exit
end
end
end