This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from heapq import heappush, heappop | |
| from itertools import combinations | |
| import networkx as nx | |
| from math import prod | |
| def no_sq_dist(p1: tuple[int, ...], p2: tuple[int, ...]) -> int: | |
| return sum(pow(a - b, 2) for a, b in zip(p1, p2)) | |
| with open("../../Data/2025/Day08") as f: | |
| puzzle = [tuple(map(int, line.split(","))) for line in f.read().splitlines()] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with open("../../Data/2025/Day07") as f: | |
| grid = [list(row) for row in f.read().splitlines()] | |
| start_col = grid[0].index("S") | |
| rows, cols = len(grid), len(grid[0]) | |
| splits: set[tuple[int, int]] = set() | |
| all_paths = [0] * cols | |
| all_paths[start_col] = 1 | |
| for r in range(1, rows): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from math import prod | |
| with open("../../Data/2025/Day06") as f: | |
| puzzle = f.read().splitlines() | |
| OPS = puzzle[-1].strip().split() | |
| # Part 1 | |
| numbers = [list(map(int, line.strip().split())) for line in puzzle[:-1]] | |
| numbers = [list(row)[::-1] for row in zip(*numbers)] # rotate grid clockwise |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Fresh: | |
| def __init__(self, start: int, end: int) -> None: | |
| self.start = start | |
| self.end = end | |
| def __repr__(self) -> str: | |
| return f"<Range:{self.start}-{self.end}>" | |
| def add_range(ranges: list[Fresh], new: Fresh) -> list[Fresh]: | |
| result = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Optional | |
| class Range: | |
| def __init__(self, source: int, length: int) -> None: | |
| self.start, self.end = source, source + length | |
| def __repr__(self) -> str: | |
| return f'<Range [{self.start} - {self.end}]>' | |
| class Translation: |
NewerOlder





