Deshaw Inc Interview Question
Software Engineer / DevelopersThis can be explained in the following way.
The cubes that have all the three faces painted will be on the eight corners of the Bigger cube.So 3 sides painted = 8.
Now the cubes with two sides painted will be the one that are on the edges of the Bigger cube ( obviously not considering the ones on the corner). As we have 12 edges in a cube, so it comes down to 12(n-2). (n-2) can be explained as n-(removing the two corner cubes, 1 from each side).
Cubes with only one side painted will be the one on the face of the Bigger cube except the ones on the edges and the corners. This comes down to 6*(n-2)^2.
And the rest of them are unpainted cubes
Cheers
0 : 1
- Vish February 14, 20081 : 6
2 : 12
3 : 8
4 : 0