Skip to content

Instantly share code, notes, and snippets.

@dropkickfish
Created December 1, 2020 22:53
Show Gist options
  • Save dropkickfish/a67762027fe628b0a81a2f593c634858 to your computer and use it in GitHub Desktop.
Save dropkickfish/a67762027fe628b0a81a2f593c634858 to your computer and use it in GitHub Desktop.
Advent of Code 2020 Day 1
array = []
File.foreach("input1.txt") { |line| array << line.to_i }
pairs = array.combination(ARGV[0].to_i)
pairs.each do |pair|
if pair.sum == 2020
puts pair[0..-1].reduce(:*)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment