My solutions to Advent of Code puzzles, implemented in MATLAB.
MATLAB is my primary language from my Computational Engineering studies, and it's where I'm most confident writing code. I use Advent of Code as a way to sharpen algorithmic problem-solving within a language I already know well.
2024/
day1.m
day2.m
...
2025/
day1.m
day2.m
...
| Year | Stars |
|---|---|
| 2024 | 25/50 |
| 2025 | 19/24 |
- File I/O and data handling for parsing puzzle input into usable formats
- Regular expressions (
regexp) for extracting patterns from text - Text handling and parsing (
split,contains) - Array repetition (
repmat,repelem) - Logical checks across arrays (
all,any) - Other core functions:
unique,fprintf - Bitwise operations (
bin2dec,bitxor,bitand) - Logical operators
||and&&for combining conditions - Using
~as a logical NOT operator - Solving systems of linear equations with
rrefinstead of brute-forcing combinations - Working with cell arrays for handling mixed or irregular data
- Iterative problem-solving using for-loops
- Generating combinations with
nchoosekto brute-force operator placements - Reading raw text input with
fileread - Using sentinel values (
inf,NaN) in cell arrays to represent "empty" or placeholder data during simulation - Implementing a small boolean logic gate simulator (AND/XOR/OR) and
converting the resulting bits back to decimal with
bin2dec
- Continued building visualizations for puzzles (Day 4, Day 7) to better understand and debug problem logic
- New functions:
isbetween,rmmissing,strcat,convertCharsToStrings
- Day 6: Built a visualization of the guard's path through
the grid to help debug the logic and make the solution easier to understand.
Also used a
tic/toctimeout as a practical way to detect infinite loops, instead of implementing full cycle detection. - Day 7: Used
nchoosekto generate every possible combination of operators (+ and ×) between numbers, rather than solving it recursively. - Day 9: Simulated disk defragmentation by representing
free space with sentinel values (
inf/NaN) in cell arrays, then compacting blocks from the end of the disk into the gaps. - Day 11: The stone count grows exponentially with each
step, making a brute-force list impossible to handle after enough iterations.
It took me about a month to find the fix — instead of tracking every stone
individually, I split the list into unique values and their counts, solving
each unique value only once. Also used
parforto parallelize the loop and speed up execution. - Day 13: Recognized the puzzle as a system of linear
equations and solved it directly with
rref, rather than searching through possible button-press combinations. - Day 14: Simulated robot movement on a grid and used a
spyvisualization to search for the moment the robots formed a hidden picture (a Christmas tree) — the visualization itself was the solution method, not just a debugging aid. - Day 24: Built a small logic-gate simulator that
evaluates AND/XOR/OR gates iteratively until the whole circuit resolves,
then reconstructs the binary output with
bin2dec.
- Day 3: Used a greedy approach to find the largest possible digit at each position while still leaving enough digits for the rest of the number.
- Day 4: Built a visualization of the puzzle to make the logic easier to follow.
- Day 7: Built a visualization of the puzzle to make the logic easier to follow.
- Day 8: Implemented a Kruskal's-algorithm-style approach to connect points by increasing distance and group them into circuits (connected components), stopping once all points were paired.
- Day 11: Learned and applied depth-first search (DFS) and breadth-first search (BFS) to solve the puzzle. Timing comparisons in the code show just how much the choice of algorithm mattered here — the DFS approach took up to 6 minutes on one part of the puzzle, while BFS solved the same part in little over 2 minutes.
Advent of Code asks that puzzles be solved without AI assistance, since they're designed as a human problem-solving exercise. In that spirit, all puzzle solutions in this repository were written independently, without AI help. This README, however, was drafted with AI assistance (Claude) to help organize and phrase the content.
MIT