def find_product_of(n) puts File .readlines("input.txt") # read input lines as array entries .map(&:to_i) # convert each array entry to integer .permutation(n) # create Enumerable with all permutations of n entries .find { |array| array.sum == 2020} # find a permutation that sums to 2020 .inject(:*) # get the product of that array end puts "Part 1: " find_product_of(2) puts "Part 2: " find_product_of(3)