Cube Solver

May 31, 2016

Had a little fun today at work with this little wooden cube puzzle. It consists of smaller alternating color cubes strung together in a way where the final result is a larger 3x3 cube when the smaller blocks are placed correctly.

Having had written a simple sudoku solver before using the recursive backtracking, I thought a solver could be written up fairly quickly using the same technique.

The way my solver works is by recusively trying to place the smaller 1x1 within a larger “virtual” 3x3 cube. It runs through each segment and places each block when it can, and if it can’t it’ll backtrack to the last successful call and continue trying to solve from there. Although it’s recursive it doesn’t run into any stack overflow problem because the size of the cube is quite small (total of 27 blocks inside), and the constraints are so limiting that it doesn’t travel too deep without seeing a problem.

I’ve made the code available on my github for anyone curious to see it, here.

And here’s the cube after being solved. :D

For those who don’t know, Let’s Encrypt is now in public beta so those who could not afford to secure their site before will now be able to at no cost. This site is now secured and there’s no reason for anyone to not secure their’s as well. Do it now!

PS. My game has been approved and is up on the iTunes App Store! Download it Here!

I just completed my first game for ios, LetterBlocks. It’s a boggle style of game, where the goal is to create as many words as you can before the timer runs out.

It was really my first step into iOS game development, and also served as an introduction to the programming language, Swift. Building a game alone is very time-consuming, especially the non-programming side of things, which is why this game had quite minimal art.

SpriteKit was used as the game engine because it was introduced by Apple, and it is slightly easier to get going than other libraries/engines. Although the experience with SpriteKit was good, I would probably be switching to something else for any further games as building something for iOS only is kind of a deal-breaker.

Anyway, it’s been submitted and currently awaiting a review and the suspense is really killing me because it is my first app to be submitted to the app store. Hopefully it all goes well and I don’t get rejected! For now i’m in brainstorm mode for my next game idea and I’ll try to make something actually fun this time around.

© 2021 Borin Ouch