initial solution for second challenge
parent
39c3269366
commit
c72dfaa5e7
|
@ -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
|
Loading…
Reference in New Issue