Using BFS to solve Rush Hour

Part 1 | Part 2 | Parts 3 & 4 | Part 5

Challenge 6: Rush Hour

Rush Hour is a famous puzzle game where you slide vehicles to unjam a red car to freedom. It’s a nice game - I spent hours with it as a kid!

In this challenge you’ll apply BFS to solve Rush Hour puzzles. Some directions:

  • You’ll receive a list describing vehicle positions, with a color and a list of occupied cells for each vehicle
  • The aim is for the red car to arrive at the red rectangle
  • This time, you’re controlling multiple objects (vehicles in this case)
    • So you need to return a list of instructions, where each instruction refers to a specific vehicle (and contains the direction this vehicle needs to move towards)
  • Another change from the previous challenge - now it’s up to you to implement board simuations and validate board states

Enjoy!

5-year blogday

This blog recently celebrated 5 years! Here’s a post from exactly 5 years ago. Turbulent as some of those years were, I’m glad I stuck to writing.