Skip to content

Instantly share code, notes, and snippets.

View nxfern's full-sized avatar

Nicolas Fernandez nxfern

View GitHub Profile
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()]
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):
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
@nxfern
nxfern / aoc2025_day05.py
Created December 5, 2025 09:27
AOC 2025 Day 05 Solultion
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 = []
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: