Skip to content
Go back

Who is up for a programming challenge?

Updated:

Is anyone still doing good, old-fashioned programming? Or is everyone prompting and trying to tame LLMs (and asking themselves why)?

Here’s a small programming challenge, a brain teaser and a balm for the soul.

Motivation

Rush Hour

The other day, my son brought home a game from the library and asked me to play with him. After playing a while I realized that not only was it very engaging (and difficult), but it also posed an interesting mathematical problem.

The game is called Rush Hour, was invented by Nob Yoshigahara in the 1970s, and is produced by ThinkFun.

Like many other puzzles, this problem is PSPACE-complete.

I know there are many solutions out there, but I want to enjoy the process of solving it myself, so I’m not going to look at them. I hope you share that sentiment and adhere to the code of honor. If you show me your solution, I promise not to look at it until I finish mine.

Challenge description

The challenge is simple. Given the initial position of the cars on the board, find a sequence of moves that will lead the red car 🚗 to the exit of the maze.

I created a getting started template with a simple reference implementation of the game (without the solver), as well as a few examples with initial positions and solutions. Feel free to choose a different starting point if it better suits your needs.

Code of conduct

Prize

Personal satisfaction. Plus, I might invite you for coffee.

FAQ

Solution

If you are really sure you want to see the solution, click below.

See solution

I implemented a solution based on the above template. This solver is a classical informed search algorithm. There are actually two solvers: one uses BFS and the other uses AA^{*}.

I also formulated the problem declaratively using JuMP, an algebraic modelling language for mathematical optimization in Julia.

Both solutions can be found in this repository, and this post describes the declarative approach in detail.


Share this post on:

Previous Post
Death, taxes and optimization
Next Post
Die Mutter aller neuen Resultate in der analytischen Mechanik