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

21
06/f.py
View File

@@ -3,17 +3,22 @@ import os
input = open(os.path.dirname(__file__) +
"/input.txt", "r").read()
index = 0
index2 = 0
index, index1, index2 = 0, 0, 0
buf = []
for x in input:
index += 1
index2 += 1
buf.append(x)
if len(buf) == 14:
if len(set(buf)) == 14:
break
else:
if index1 == 0 and len(buf) == 4:
if len(set(buf)) == 4:
index1 = index
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))