Skip to content

Instantly share code, notes, and snippets.

@redspider
Created December 1, 2020 19:14
Show Gist options
  • Save redspider/16c9c3389f09379aadb0f29cd9879be9 to your computer and use it in GitHub Desktop.
Save redspider/16c9c3389f09379aadb0f29cd9879be9 to your computer and use it in GitHub Desktop.
import itertools
import math
numbers = [int(x) for x in INPUT.split("\n")]
# Part 1
print([math.prod(match) for match in itertools.combinations(numbers, 2) if sum(match) == 2020])
# Part 2
print([math.prod(match) for match in itertools.combinations(numbers, 3) if sum(match) == 2020])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment