start
to end
such that nodes named with lowercase letters are visited once, and nodes with uppercase letters can be visited any number of times.A cute little puzzle game, where you move around snake(birds). Move any number of snakes around the level, eating fruit, and getting to the exit. The main gotchas are that you have gravity to content with–your snake will easily fall off the edge of the world–and each time you eat a fruit, your snake gets bigger. This can help get longer to get into hard to reach places or it can cause trouble when you trap yourself in corners.
Let’s use the new immutable.js solver to solve these problems!
A bit ago I wrote about writing a generic brute force solver (wow, was that really two months ago?). It got … complicate. Mostly, because every time I wrote a step
function, I had to be careful to undo the same. Wouldn’t it be nice if we could just write a step function and get backtracking for ‘free’?
Well, with immutability you can!
Oops, turns out I haven’t had a post in a good long while. Before it gets even longer, I figure that I should take one off my backlog and just write it up, even if it is a little on the shorter side.
Today’s post was inspired by this post on /r/dailyprogrammer a month ago today: Challenge #178 [Hard] Regular Expression Fractals. The basic idea is that you are going to take a rectangular region and divide it into four quadrants, again and again, recording the path as you go (images from that post):
Random quick post today1. Basically, we want to write code to generate what’s known as Look and Say sequence:
To generate a member of the sequence from the previous member, read off the digits of the previous member, counting the number of digits in groups of the same digit. For example:
- 1 is read off as “one 1” or 11.
- 11 is read off as “two 1s” or 21.
- 21 is read off as “one 2, then one 1” or 1211.
- 1211 is read off as “one 1, then one 2, then two 1s” or 111221.
- 111221 is read off as “three 1s, then two 2s, then one 1” or 312211.
Here’s another post from /r/DailyProgrammer: Advanced Langton’s Ant. I’m a bit behind the times (see tomorrow’s post), but it’s still an interesting enough exercise, so let’s go for it!