Python

How To Use Text Embeddings
How To Use Text Embeddings

Embeddings let software work with meaning rather than just matching words, so you can search by intent, find related content, and give LLMs the right context to answer questions. In this post we will start from first principles, show what these vectors actually are, explain their useful properties, …

Structured Output in LangGraph
Structured Output in LangGraph

Large language models are incredibly versatile, but when your code depends on predictable data structures, free‑form text can be a headache. The same information can be expressed in countless ways, making downstream processing error-prone. Structured output bridges this gap: by defining a schema, …

Advent of Code 2025: A Retrospective
Advent of Code 2025: A Retrospective

In software engineering, it’s typically very good to have a retrospective after a sprint of work. The goal isn’t just to celebrate successes or catalogue frustrations, but to step back and deliberately reflect: what worked well, what didn’t, and what lessons are worth carrying forward? Advent …

Advent of Code 2025: Day 12
Advent of Code 2025: Day 12

Day 12 is the last day of Advent of Code 2025, and the last day is historically quite easy. The puzzle today looks like a polyomino packing puzzle at first glance, but for this input it reduces neatly to a capacity check on occupied cells per region. This was an assumption on my part because of the …

Advent of Code 2025: Day 11
Advent of Code 2025: Day 11

Day 11 is about counting all possible paths through a graph between two specific nodes. This sort of problem is best solved with a depth-first search using memoisation. A tiny bit of state is added in to enforce constraints in Part 2.

The whole thing runs in well under a millisecond per part on my …

Advent of Code 2025: Day 10
Advent of Code 2025: Day 10

Day 10 is by far the hardest puzzle so far in 2025. First a classic bit-flipping puzzle that reduces to XOR over bitmasks, then a minimal-presses counter puzzle modelled as an integer optimisation. If you want to follow the whole series, check out the tag page at Advent of Code, and you can browse …

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 …