day 6
This commit is contained in:
parent
6593f7e0ea
commit
24746efbd3
24
2022/06/01.py
Executable file
24
2022/06/01.py
Executable file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
INPUT_FILE = 'input'
|
||||
|
||||
WINDOW_SIZE = 4
|
||||
|
||||
def main():
|
||||
content = map(str.strip, open(INPUT_FILE, 'r').readlines())
|
||||
for line in content:
|
||||
seen_chars = []
|
||||
char_pos = 0
|
||||
for char in line:
|
||||
char_pos += 1
|
||||
if len(seen_chars) == WINDOW_SIZE:
|
||||
seen_chars.pop(0)
|
||||
seen_chars.append(char)
|
||||
if len(set(seen_chars)) == WINDOW_SIZE:
|
||||
print(seen_chars, char)
|
||||
print(char_pos)
|
||||
break
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
24
2022/06/02.py
Executable file
24
2022/06/02.py
Executable file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
INPUT_FILE = 'input'
|
||||
|
||||
WINDOW_SIZE = 14
|
||||
|
||||
def main():
|
||||
content = map(str.strip, open(INPUT_FILE, 'r').readlines())
|
||||
for line in content:
|
||||
seen_chars = []
|
||||
char_pos = 0
|
||||
for char in line:
|
||||
char_pos += 1
|
||||
if len(seen_chars) == WINDOW_SIZE:
|
||||
seen_chars.pop(0)
|
||||
seen_chars.append(char)
|
||||
if len(set(seen_chars)) == WINDOW_SIZE:
|
||||
print(seen_chars, char)
|
||||
print(char_pos)
|
||||
break
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue
Block a user