diff options
| author | nekineki <nekineki@nekineki.net> | 2025-12-16 15:05:55 +0100 |
|---|---|---|
| committer | nekineki <nekineki@nekineki.net> | 2025-12-16 15:05:55 +0100 |
| commit | 00f949917a0fe384b758018f4f23014f0c235321 (patch) | |
| tree | 78984b70c0aaf74132737afc42046e88cc9c8f44 /2025/day12.py | |
| parent | c245d85f3d488b0c580f7fe6b44147abb775ee20 (diff) | |
day12 attemptmain
Diffstat (limited to '2025/day12.py')
| -rwxr-xr-x | 2025/day12.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/2025/day12.py b/2025/day12.py new file mode 100755 index 0000000..7fb7c08 --- /dev/null +++ b/2025/day12.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 +from functools import reduce +from re import findall +from copy import deepcopy +import sys +# import numpy as np + +filename = sys.argv[1] if len(sys.argv) == 2 \ + else "in/" + sys.argv[0].split('/')[-1].rstrip(".py") + ".pzl" +data = open(filename).read() +blocks = data.rstrip('\n').split('\n\n') + +res1 = 0 +res2 = 0 + +S = [] +for i, block in enumerate(blocks[:-1]): + s = 0 + for line in block.split('\n')[1:]: + for c in line: + if c == '#': + s += 1 + S.append(s) + +print(S) + +for line in blocks[-1].split('\n'): + l, r = line.split(':') + x, y = l.split('x') + x, y = int(x), int(y) + + sh = [int(i) for i in r.strip().split(' ')] + + a = sum([i*j for i, j in zip(sh, S)]) + print(a / (x*y)) + + + +print('res1:', res1) +print('res2:', res2) + |
