Do both in one go and bit of clean up

This commit is contained in:
2022-12-06 07:31:45 +02:00
parent 51dd7d367a
commit f9ace9f63d

23
06/f.py
View File

@@ -3,17 +3,22 @@ import os
input = open(os.path.dirname(__file__) + input = open(os.path.dirname(__file__) +
"/input.txt", "r").read() "/input.txt", "r").read()
index = 0 index, index1, index2 = 0, 0, 0
index2 = 0
buf = [] buf = []
for x in input: for x in input:
index += 1 index += 1
index2 += 1
buf.append(x) buf.append(x)
if len(buf) == 14: if index1 == 0 and len(buf) == 4:
if len(set(buf)) == 14: if len(set(buf)) == 4:
break index1 = index
else: buf.pop(0)
buf.pop(0)
print(index) if index2 == 0 and len(buf) == 14:
if len(set(buf)) == 14:
index2 = index
break
buf.pop(0)
print("First answer: " + str(index1))
print("Second answer: " + str(index2))