Preparing for Advent of Code: A Python Techniques Roadmap
· by Michael Doornbos · 776 words
Advent of Code just wrapped up, and I’ve been taking notes. This year marked a change: after ten years of 25-day marathons, Eric Wastl trimmed it to 12 days. Looks like this is the format going forward—more sustainable for everyone involved.
But I’m not here to talk about the puzzles themselves. I’ve been tracking the techniques that kept coming up. The patterns that separate “I solved it” from “I solved it in under a second.”
If you’re a beginner Python programmer thinking about tackling AoC next year, this guide maps out what you need to learn. I’ve written detailed articles on each topic—this page is your starting point.
Why Python? It’s concise, readable, and has excellent built-in data structures. The standard library covers most of what you need without hunting for packages. But any language works—people solve AoC in Rust, Go, JavaScript, TypeScript, C, C++, Java, Kotlin, Ruby, Haskell, Clojure, Elixir, Zig, Lua, Perl, even assembly. I solved Day 3 this year on a Commodore 64 in BASIC—it took 449 minutes. I’m not here to judge your choices. Most of these techniques apply universally; the syntax will just look different.
How to Approach AoC Problems
Before diving into techniques, let’s talk strategy. Every AoC problem follows a pattern: read the story (which is often deliberately verbose), extract the actual requirements, parse the input, solve part 1, then solve part 2 (which usually adds a twist that breaks naive solutions).
Don’t start coding immediately. Read the problem twice. Work through the example by hand. Make sure you understand what’s being asked before you write a single line. I’ve wasted more time implementing the wrong solution than I’ve ever spent thinking through the problem first.
Part 2 is designed to break brute force. If your part 1 solution runs in O(n²) and part 2 increases n by a factor of a million, you need a better algorithm, not a faster computer. When you see part 2, ask yourself: “What assumption from part 1 no longer holds?”
The Learning Path
Here’s the priority order for preparing for AoC 2026:
Foundation (Master These First)
Part 1: Foundation Skills covers the essentials you’ll use in every single puzzle:
- String parsing —
split(),join(), slicing. Every problem starts with turning text into data. - List comprehensions —
[x*2 for x in items if x > 0]is more readable and faster than loops with append. - Sets and dictionaries — Know when to use each. “Is it present?” means set. “How many?” means dict.
- Counter and defaultdict — The standard library tools that eliminate boilerplate.
Core Skills (Learn These Next)
Part 2: Core Skills covers the techniques that solve the majority of puzzles:
- 2D grid navigation — Parsing grids, iterating cells, finding neighbors with bounds checking. Half the puzzles involve grids.
- The modulo trick — Circular structures, wrapping coordinates, rotating directions.
% nkeeps values in range. - Batch updates — When updating cells based on neighbors, collect changes first, apply second.
- BFS and DFS — The two graph traversal algorithms. BFS for shortest path, DFS for exploring all possibilities.
- Recursion with memoization — When brute force is too slow,
@lru_cacheturns exponential into instant. - Bitmasks for state — Track small sets as integers. Hashable, fast, compact.
Advanced Techniques (For Harder Problems)
Part 3: Advanced Techniques covers the algorithms you need when the basics aren’t enough:
- Dijkstra’s algorithm — Shortest path when edges have different costs.
- Backtracking — Try something, recurse, undo if it doesn’t work. Essential for constraint satisfaction puzzles.
- Union-Find — Track connected components that merge over time.
The Real Lesson
Here’s what I’ve learned from years of Advent of Code: the puzzles aren’t really about clever algorithms. They’re about recognizing which technique fits the problem.
Day 1 looks like simulation but it’s really modular arithmetic. Day 7 looks like set operations but part 2 needs counting. Day 12 looks impossible until you recognize it’s backtracking.
The techniques in these guides aren’t exotic. They’re fundamental. String parsing, grid traversal, recursion, memoization, sets, dictionaries. Learn them well enough that reaching for the right tool becomes automatic.
Next December, when you’re staring at a puzzle at midnight, you won’t be thinking about algorithms. You’ll be thinking “this is a grid problem with connected components” and your fingers will already be typing the Union-Find class.
That’s the goal. That’s what practice gives you.
The complete series:
- Part 1: Foundation Skills — String parsing, list comprehensions, sets and dictionaries
- Part 2: Core Skills — 2D grids, modulo, batch updates, BFS/DFS, recursion, bitmasks
- Part 3: Advanced Techniques — Dijkstra’s algorithm, backtracking, Union-Find
And when December rolls around, head to adventofcode.com for the puzzles.