diff options
author | mhsn <mail@mhsn.net> | 2025-09-12 20:20:58 +0100 |
---|---|---|
committer | mhsn <mail@mhsn.net> | 2025-09-12 20:36:09 +0100 |
commit | 6b733982f9f240c1c97f1fa705bfbe4cd93c640e (patch) | |
tree | dad623203c8bb40f372e0ea14479c2f564efda79 /2024/06/python/main.py | |
parent | 9299c4ef655b88eb8b571864c939c78b27f77723 (diff) | |
download | aoc-6b733982f9f240c1c97f1fa705bfbe4cd93c640e.tar.gz aoc-6b733982f9f240c1c97f1fa705bfbe4cd93c640e.zip |
simplify python file structure
Diffstat (limited to '2024/06/python/main.py')
-rw-r--r-- | 2024/06/python/main.py | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/2024/06/python/main.py b/2024/06/python/main.py deleted file mode 100644 index 5fd6c3d..0000000 --- a/2024/06/python/main.py +++ /dev/null @@ -1,55 +0,0 @@ -from fileinput import input - -obstacles = set() -seen = set() - -xmax, ymax = 0, 0 -for idy, line in enumerate(input()): - ymax = max(ymax, idy) - for idx, c in enumerate(line.strip()): - xmax = max(xmax, idx) - match c: - case "^": - pos = complex(idx, idy) - dir = 0 - 1j - case "#": - obstacles.add(complex(idx, idy)) - - -def is_loop(pos, obst): - seen_ = set() - dir = 0 - 1j - while 0 <= pos.real <= xmax and 0 <= pos.imag <= ymax: - if (pos, dir) in seen_: - return True - seen_.add((pos, dir)) - if pos + dir in obstacles or pos + dir == obst: - # Rotate cw - dir *= 1j - continue - pos += dir - return False - - -gold = 0 -for idx in range(xmax + 1): - for idy in range(ymax + 1): - if complex(idx, idy) == pos: - continue - else: - gold += is_loop(pos, complex(idx, idy)) - - -while 0 <= pos.real <= xmax and 0 <= pos.imag <= ymax: - seen.add(pos) - if pos + dir in obstacles: - # Rotate cw - dir *= 1j - continue - pos += dir - - -silver = len(seen) - -print("silver:", silver) -print("gold:", gold) |