Advent of Code
Paul Waring (paul@xk7.net)
10th November 2026
whoami
- Freelance PHP developer and Linux system administrator
- Director of IT & Chief Security Officer
- Specialise in legacy code/systems and financial services
- I like trains, Doctor Who and technology (@pwaring@social.xk7.net)
- You may know me from: Geek Walks, Currybeer (but not golf or
moths)
Topics
- What is Advent of Code?
- Language options
- Tips
- Testing
- Examples in Go and C
- Questions at any time
What is Advent of Code?
- Annual coding challenge in December
- Every year since 2015
- 1 puzzle (in two parts) per day for 12 days (down from 25)
- Each puzzle involves helping elves save Christmas
- 100,000+ participants each year
- Free to take part
- Supported by sponsorship, donations and merchandise
What is Advent of Code?
- Puzzles get progressively (but not linearly) harder as time goes
on
- Your input and answer are unique (c.f. Project Euler,
everybody.codes)
- Brute-force solutions often don’t work
- Puzzles are always available, can try previous years
- Deliberately designed not to require programming knowledge
What is Advent of Code?
- Don’t have to solve puzzle n to unlock n+1
- Do have to solve part 1 to unlock part 2
- Part 2 often requires you to rethink your solution
- Unofficial part 3 options published to Reddit
Leaderboards
- Points based on who is first, second etc. to solve a puzzle
- Puzzles released at midnight EST - 05:00 GMT
- Global leaderboard filled up very quickly (within 5-10
minutes)
- Speed solvers don’t use same methods as everyone else
- No global leaderboard from 2025 onwards
- Private leaderboards (one per account, join as many as you
want)
Languages
- Use any languages you want
- Some languages might suit different puzzles
- Familiar language: solve quickly
- Choose a language you want to learn / improve
- Maybe a different paradigm, e.g. functional vs imperative
- C or Go are my choices most years
C
- Challenge: Standard library only, C99
- Unity is an easy
to use test framework
- Write tests as C functions with 1+ assertions
- Include as a submodule
- Bash script to build each solution
Go
- Use the latest version: generics, slices etc.
- One directory per puzzle part
- heredoc:
Embedding strings for tests
- testify: Better
assertions / testing
- lo: Maps, filters, reduce
etc.
Tips
- Read the puzzle descriptions carefully
- Edge cases often catch people out
- Think about possible interpretations
- Create a sensible filesystem structure
Tips
- Write tests
- Read the input in one go (especially with C)
- Build simple data structures - as many as you need
- Don’t worry about optimisation to start with
Tips
- Don’t get disheartened - days >10 are usually difficult
- Sometimes puzzles are ambiguous
- Ambiguous: easy vs impossible
- Focus on algorithms and data structures
- Lots of support, especially /r/AdventOfCode and #AdventOfCode
Testing
- Testing really helps, even for seemingly simple puzzles
- Break every step into a separate function for testing
- Get test input working first - but beware of edge cases
Thanks for listening
- Questions?
- Slides at: phpdev.uk/talks