mirror of
https://github.com/thib8956/advent-of-code.git
synced 2025-08-24 00:11:57 +00:00
chore: create new project structure and aoc.py runner script
This commit is contained in:
24
adventofcode/2020/day1/day1.py
Normal file
24
adventofcode/2020/day1/day1.py
Normal file
@@ -0,0 +1,24 @@
|
||||
#! /usr/bin/env python3
|
||||
from itertools import product
|
||||
|
||||
|
||||
def part1(inp):
|
||||
inp = [int(x) for x in inp]
|
||||
result_pairs = [x for x in list(product(inp, inp)) if sum(x) == 2020]
|
||||
print(result_pairs)
|
||||
print(result_pairs[0][0] * result_pairs[0][1])
|
||||
|
||||
|
||||
def part2(inp):
|
||||
inp = [int(x) for x in inp]
|
||||
result_pairs = [x for x in list(product(inp, repeat=3)) if sum(x) == 2020]
|
||||
print(result_pairs)
|
||||
print(result_pairs[0][0] * result_pairs[0][1] * result_pairs[0][2])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import fileinput
|
||||
lines = [x for x in fileinput.input()]
|
||||
part1(lines)
|
||||
part2(lines)
|
||||
|
Reference in New Issue
Block a user