You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
543 B
26 lines
543 B
2 years ago
|
with open('input6.txt','r') as f:
|
||
|
inp = f.read().splitlines(keepends=False)
|
||
|
|
||
|
inp = inp[0]
|
||
|
|
||
|
for i in range(3, len(inp)):
|
||
|
tempa = inp[i - 3:i+1]
|
||
|
tempc = 0
|
||
|
for x in tempa:
|
||
|
tempc += tempa.count(x)
|
||
|
if tempc == 4:
|
||
|
paketstart = i + 1
|
||
|
break
|
||
|
|
||
|
print('Start of packet', paketstart)
|
||
|
|
||
|
for i in range(13, len(inp)):
|
||
|
tempa = inp[i - 13:i+1]
|
||
|
tempc = 0
|
||
|
for x in tempa:
|
||
|
tempc += tempa.count(x)
|
||
|
if tempc == 14:
|
||
|
messagestart = i + 1
|
||
|
break
|
||
|
|
||
|
print('Start of Message', messagestart)
|