Fun little tree-walking puzzle. Nothing terribly fancy here. I could have been a bit more clever with the second part but … it gets the job done. And sometimes that’s the most important thing.
Happy Feast of St. Nicholas!
Read more →
Now this is the sort of problem I love! I don’t know why, but I really enjoy writing little state machines.
Read more →
I misread this one over and over and over — little-known fact: ‘increase’ and ‘decrease’ mean different things. Ended up stealing from https://chrispenner.ca/posts/advent-of-optics-04 . Oh well, there’s always tomorrow.
Read more →
I am embarrassed that I spent ages playing with how to detect line intersections before I finally just brute-forced it with hash tables.
Read more →
This one was fun, building a very simple little ‘intcode’ (like bytecode, but more than 256 possibilities) interpreter.
Read more →
I decided to give the Advent of Code another shot this year (last year I gave it a shot, but work commitments ended up devouring all of my formerly-free time and I had to give it a miss). As before, I’ll be tracking my solutions.
Today was very easy, no real comments needed.
Read more →
Yesterday’s solution was awesome: I read the problem, walked my dog, then sat down at the computer and wrote both solutions perfectly, one after the other. First time I managed to do that!
Today took a bit longer. The difficult thing was coming up with a heuristic for knowing when the stars aligned to give a message, without manually reviewing each possible image. My first idea was to somehow calculate entropy across the grid of stars (and find the lowest-entropy frame), but a quick Googling didn’t really yield anything which was likely to help.
Read more →
All I’m going to say about today’s solutions is read the problem carefully. I missed a key fact, which meant I spent way too much time handling cases I didn’t need to. There’re still some vestiges of that approach in the (working) solutions.
Sheesh.
Read more →
I’ve got today’s solutions up. This problem wasn’t really amenable to using hashes, so I just brute-forced it with a 1,000×1,000-element array (hey, memory is cheap!). FIND-VALID-CLAIMS is O(n²) (due to a O(n) list deletion performed O(n) times), but … CPU is cheap too, and these are puzzles, not production code. That’s a running theme throughout these solutions: I’m not playing for high-performance or highly-elegant solutions to the puzzles, just the correct answers, quickly.
Read more →
I’ve got my solutions to today’s puzzles up. Believe it or not, a lot of folks dislike LOOP because it’s not terribly Lispy — they’re right, of course, but it is a pretty handy Swiss Army knife to keep in one’s pocket.
I use hash tables a lot, but that’s because hash tables are an awesome data structure. My biggest takeaway from working on these puzzles so far is gratitude that Common Lisp is a large enough language that it has hash tables; were I writing in C I’d either be scanning & rescanning & re-rescanning strings, or I’d have to write my own hash table implementation.
Read more →
I’ve decided to participate in the Advent of Code this year. The idea is that each day two simple puzzles are released, and folks use their favourite programming language to solve them. Folks compete to be the first person to submit a solution (only the first 100 count for points, though). Following Javier Olaechea’s example, I’ll track each day’s solution and post notes here.
Sum numbers I decided to just drop the input in as a string.
Read more →
Back in 2007 Peter Norvig shared a simple spelling corrector (last
updated in 2016); I thought that I’d share my translation into Lisp,
with some comments. Norvig’s original article explains the actual
algorithm he’s using; I’ll focus on stuff specific to my own version.
I’m definitely not a Lisp wizard (although I’ve been using it for many
years), so it’s entirely possible that I’ve messed one thing or
another up — I’m glad to receive corrections or comments.
Read more →