DocSpring Blog

BTC 2018 Solutions - Stage 2: Cubes

This blog post contains the solution for Stage 2 of the 2018 Bitcoin Programming Challenge.

I saw the first episode of 3% in early 2018. There is a scene where the contestants have to form 9 cubes from a set of blocks.

3% Screenshot - Cubes
Screenshot from Chapter 01: Cubes. Watch 3% on Netflix.

I thought this might be an interesting programming challenge. I decided to encode a Bitcoin private key inside a solved cube, and then split up the cube in a set of blocks.

The Cubes challenge is hosted here. (You were given this URL after you solved all of the CSS puzzles in PixelPerfect.)

I used the Ruby programming language to write the puzzle generator and reference solution. I did some “test-driven development” with RSpec to make sure that everything was working. I found it very difficult to visualize the 3D shapes and see if all the rotations and translations were correct, so I wanted to render some 3D scenes. I found the mittsu library, which is a 3D graphics library for Ruby. I could have also used OpenSCAD or Blender (with some Python scripts), but it was a lot of fun to play with the mittsu library. They have some great examples that were very easy to understand and modify.

I created a puzzle_generator.rb scene, and this was incredibly useful. This vizualization allowed me to cycle through all of the different puzzle pieces and see how they fit inside the cube. I could also rotate the pieces around the difference axes to ensure that my rotation code was correct.

Once you figure out how to do the 3D rotations and translations, it’s not too difficult to brute-force the solution. I was thinking about making the puzzle really difficult, so that it would take around 30 minutes to brute-force on a decent CPU. I decided that this would be a bad idea and I just made it very simple, because I wanted to be 100% sure that there was only a single solution. I made a few mistakes in my first Bitcoin challenge, so I wanted to avoid any ambiguity. I might have gone too far in the other direction this time, but hopefully I made up for that in stage 4!

The source code for the Cubes challenge has now been published on GitHub:

The winner has also posted an amazing write-up about how they solved the puzzles.


Solutions for the 2018 Bitcoin Programming Challenge: