Monday, April 14, 2008

Tough Interview Question #43: The Macro Cube

Q: Picture a 10×10x10 “macro-cube” on the table. This big cube is made up of 1×1x1 “micro-cubes”. Your dog walks by and knocks the macro cube off with his tail, causing it to crash to the ground. When it hits, the impact causes the entire outer layer of micro-cubes to fall off. How many micro-cubes are on the floor?


A: First, don’t beat the dog, he was just happy to see you. This is a popular question and you should be ready for it. There are a couple ways to solve this. The first (not the best), is to count the number of cubes on each face and add them up. This math is confusing for most people.
The better solution is to focus on the structure of the problem. The original macro-cube and new smaller macro-cube hold the answer. The difference between their volumes is how many micro-cubes fell off. The volume of a cube is n cubed. The answer is, therefore, 10 cubed - 8 cubed. So, 1,000 - 512 = 488.

Note: A common mistake is for people to think because only one layer fell off, the solution is 10 cubed - 9 cubed.



Jeff Altman 
The Big Game Hunter
www.TheBigGameHunter.us
JeffAltman@TheBigGameHunter.us


No comments: