Color Cubes Puzzle - Solved in Ruby
Do you know this puzzle? The idea is that you must place all the cubes in the container so that one of each color is showing on all 4 sides. A very simple problem, but since every dice can be rotated in 24 different ways (yes, not six), there are 24^4 = 331776 different possibilities. Admittedly, the permutation of the dice doesn’t matter (reduces the number with a factor of 4! = 24), and the orientation of all the dice together doesn’t matter either (there’s no up/down/left/right) which means we can reduce the number by another factor of 4.
This means there are approximately (24^4)/(4!*4) = 3456 ways to put the cubes inside the box. This may be reduced a bit further, but I think it’s a good approximation.
Well, after giving up on it last night I decided to try let my computer solve it, and because 331776 isn’t that big a simple brute force was enough.
I wrote my little solver in ruby, and it took me a couple of hours to get it right—or rather, almost right. But what really puzzles me is the solutions. They are correct, but I would expect at least 4!*4 since I’m just doing a plain brute force which would see all the different permutations (4!) and rotations (4) as different solutions. But how many did I find? Not 4!*4, not 4!, not 4 but 8. Why 8? I have no idea, but they work :) (hey! if you have any idea, please contact me)
The script I used can be found here if anyone wants it.
At last, try to read what this store has to say about the puzzle.
Of the 365 possible combinations, only ONE of them is right! This one will drive you batty!
huh? 365, where did 365 come from? I guess he means 3456 or I missed something really obvious :)







