Jump Out Of A Nested Context With Throw/Catch
answer =
catch do |obj|
input.each_with_index do |input1, x|
input.each_with_index do |input2, y|
next unless x != y
next unless input1 + input2 == 2020
throw(obj, input1 * input2)
end
end
raise StandardError, 'No answer found'
end
puts answerLast updated