summaryrefslogtreecommitdiff
path: root/2024/06/python
diff options
context:
space:
mode:
authormhsn <mail@mhsn.net>2025-09-12 20:20:58 +0100
committermhsn <mail@mhsn.net>2025-09-12 20:36:09 +0100
commit6b733982f9f240c1c97f1fa705bfbe4cd93c640e (patch)
treedad623203c8bb40f372e0ea14479c2f564efda79 /2024/06/python
parent9299c4ef655b88eb8b571864c939c78b27f77723 (diff)
downloadaoc-6b733982f9f240c1c97f1fa705bfbe4cd93c640e.tar.gz
aoc-6b733982f9f240c1c97f1fa705bfbe4cd93c640e.zip
simplify python file structure
Diffstat (limited to '2024/06/python')
-rw-r--r--2024/06/python/main.py55
-rw-r--r--2024/06/python/pyproject.toml6
2 files changed, 0 insertions, 61 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)
diff --git a/2024/06/python/pyproject.toml b/2024/06/python/pyproject.toml
deleted file mode 100644
index 8ad63e7..0000000
--- a/2024/06/python/pyproject.toml
+++ /dev/null
@@ -1,6 +0,0 @@
-[project]
-name = "aoc-2024-06"
-version = "0.1.0"
-description = "advent of code 2024-06"
-requires-python = ">=3.13"
-dependencies = []