day9pt1
This commit is contained in:
32
day9/day9.py
32
day9/day9.py
@@ -1,12 +1,34 @@
|
|||||||
|
def valid(num, previous):
|
||||||
|
for i in range(0, len(previous)):
|
||||||
|
for j in range(0, len(previous)):
|
||||||
|
if previous[i] + previous[j] == num:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def part1():
|
def part1():
|
||||||
file = open("input_test.txt")
|
file = open("input.txt")
|
||||||
|
|
||||||
preamble_length = 5
|
preamble_length = 25
|
||||||
|
lines = file.readlines()
|
||||||
|
|
||||||
for line in file:
|
queue = []
|
||||||
pass
|
|
||||||
|
|
||||||
print("Part 1: %d")
|
for i in range(0, preamble_length):
|
||||||
|
number = int(lines[i])
|
||||||
|
queue.append(number)
|
||||||
|
|
||||||
|
for i in range(preamble_length, len(lines)):
|
||||||
|
number = int(lines[i])
|
||||||
|
|
||||||
|
if not valid(number, queue):
|
||||||
|
break
|
||||||
|
|
||||||
|
queue.pop(0)
|
||||||
|
queue.append(number)
|
||||||
|
|
||||||
|
print("Part 1: %d" % number)
|
||||||
|
|
||||||
|
|
||||||
def part2():
|
def part2():
|
||||||
|
|||||||
Reference in New Issue
Block a user