Python

Advent of Code 2025: Day 09
Advent of Code 2025: Day 09

Day 9 asks for the largest axis-aligned rectangle defined by any two corner coordinates in the input. It then graduates to validating that a candidate rectangle must lie wholly inside the rectilinear loop traced by those corners. Part 1 is a straightforward exhaustive search over corner pairs with …

Advent of Code 2025: Day 08
Advent of Code 2025: Day 08

Day 8 is all about finding edges between 1,000 nodes in a graph, each with a 3D set of integer coordinates. Graphs can be computationally expensive if the wrong types are used, but my solutions run in under a second for each part of the puzzle. Let’s take a look at the puzzle specifics and how …

Advent of Code 2025: Day 07
Advent of Code 2025: Day 07

Day 7 models a downward beam traversing a grid of splitters, and a single dynamic programming pass prepares everything we need for both parts. Part 1 counts where a straight descent is blocked by a splitter and turns into a left–right split, while Part 2 totals the many‑worlds outcomes that land on …

Advent of Code 2025: Day 06
Advent of Code 2025: Day 06

Day 6 presents a neat parsing twist where the same worksheet must be interpreted in two different ways, and a small amount of transposition and reduction logic solves both parts cleanly. We will outline what each part asks for, then walk through a compact Python implementation that builds …

Advent of Code 2025: Day 05
Advent of Code 2025: Day 05

Day 5 serves up two courses: a quick taste test to check whether each ingredient is fresh according to ranges of fresh items. Then a hearty main where we reduce overlapping ranges of the fresh items and identify how many unique ingredients are included. We manipulate the input into integers for …

Advent of Code 2025: Day 04
Advent of Code 2025: Day 04

Day 4 boils down to counting and then repeatedly removing rolls of paper that have fewer than four neighbouring rolls. A small Grid2D helper plus a couple of concise functions are all you need. We will go over the rule for a roll being accessed, show how to parse the grid and inspect eight-way …

Advent of Code 2025: Day 03
Advent of Code 2025: Day 03

Day 3 builds a number from digits by picking a subsequence with the largest possible value, and the same greedy approach powers both parts. We will unpack the problem requirements at a high level, then walk through a compact Python solution that selects the maximum value subsequence per digit …

Advent of Code 2025: Day 02
Advent of Code 2025: Day 02

Day 2 of Advent of Code 2025 is a satisfying dive into pattern detection over numeric ranges, starting with pairs of repeated digit sequences and then generalising to any number of repeats. The Python solution below uses straightforward string slicing and chunking to get the job done with clear, …

Advent of Code 2025: Day 01
Advent of Code 2025: Day 01

Day 1 of Advent of Code 2025 is a neat exercise in modular arithmetic, where you track a circular dial and count how often it hits zero. Part 1 counts only the zeros landed on at the end of rotations, and Part 2 upgrades that to count every click that passes through zero mid-rotation too. In this …

Pausing for Human Feedback in LangGraph
Pausing for Human Feedback in LangGraph

Adding a human-in-the-loop step to a LangGraph flow is an easy way to improve quality and control without adding branching or complexity. In this post we will build a tiny three-node graph that drafts copy with an LLM, pauses for human feedback, and then revises the draft, using LangGraph’s …

Advent of Code 2025: Preparations
Advent of Code 2025: Preparations

Advent of Code 2025 is almost here, and this year I am aiming squarely at speed and optimisation across all 12 puzzles using Python and UV. I will publish a short post every day covering the approach and performance choices, and you are very welcome to join in using whichever language you want to …

Sudoku Series: Implementing Wing Rules
Sudoku Series: Implementing Wing Rules

The next rules to implement for the Sudoku solver are called wing rules. There are a few of these rules used in solving Sudoku, but some are hard to identify and are for very advanced solves. The two needed to solve most Sudoku puzzles are called XY-Wing and XYZ-Wing:

  • XY-Wing uses a pivot cell with …