Do both in one go and bit of clean up
This commit is contained in:
23
06/f.py
23
06/f.py
@@ -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:
|
||||
buf.pop(0)
|
||||
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))
|
||||
|
||||
Reference in New Issue
Block a user