Created
December 1, 2020 19:14
-
-
Save redspider/16c9c3389f09379aadb0f29cd9879be9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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