diff options
| author | nekineki <nekineki@nekineki.net> | 2022-12-11 14:47:27 +0100 |
|---|---|---|
| committer | nekineki <nekineki@nekineki.net> | 2022-12-11 14:50:32 +0100 |
| commit | fe75c10e350743a1c078f065d69556fecf825ca5 (patch) | |
| tree | 956556a564c9329346dc9d8b1535dc5e365f3d55 /2022/day06.py | |
| parent | a74d2dc54aef546664bcc8c81eb8e01a93e94391 (diff) | |
move files around, update paths
Diffstat (limited to '2022/day06.py')
| -rwxr-xr-x | 2022/day06.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/2022/day06.py b/2022/day06.py new file mode 100755 index 0000000..5a107df --- /dev/null +++ b/2022/day06.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +# import numpy as np +from functools import reduce +from re import findall +from copy import deepcopy + + +# filename = "in/day06.ref" +filename = "in/day06.pzl" + +res1 = 0 +res2 = 0 + +def solve(n): + f = open(filename) + for line in f: + line = line.strip() + for a in range(len(line)-n): + s = set() + for i in range(0,n): + s.add(line[a+i]) + + if len(s) == n: + # print(s) + res = a + n + return res + f.close() + +res1 = solve(4) +res2 = solve(14) + +print('res1:', res1) +print('res2:', res2) + |
