ML Interview Q Series: Conditional Probability: Finding the Hidden White Face on a Painted Cube
Browse all the Probability Interview Questions here.
We have a white cube whose six faces were all painted green before being sliced into 3×3×3 (27) smaller cubes. A single small cube is chosen at random and is observed to have five of its visible faces white. What is the probability that its unseen (bottom) face is also white?
Short Compact solution
Among the 27 smaller cubes, there is exactly 1 completely internal cube whose faces all remain white, and there are 6 face-centered cubes that each have exactly one green face. For a randomly chosen cube to show five white faces, either it is the fully white center cube (which then necessarily shows 5 white faces in any orientation) or it is one of the 6 face-centered cubes oriented in such a way that the green face is hidden underneath.
The probability of picking the fully white center cube is 1/27. If that center cube is chosen, the chance of seeing five white faces is 1 (every orientation shows all-white faces). The probability of choosing any one of the 6 face-centered cubes is 6/27, and the likelihood that its single green face ends up hidden is 1/6. Therefore, the probability of observing five white faces on a randomly chosen piece is
If we define event A as “the bottom face is white” and event B as “the other 5 visible faces are white,” we want P(A∣B). Only the all-white center cube can have a white bottom face under condition B. Thus,
Hence, the probability that the bottom face is also white is 1/2.
Comprehensive Explanation
The reasoning relies on understanding which of the 27 smaller cubes can possibly show five white faces when placed on a table or in someone’s hand. The original large cube was entirely painted green on the outside, so the smaller cubes near the outer surface each carry some green sides, while the cubes deeper inside are still white on all faces.
A fully internal cube (the unique central piece in the 3×3×3 arrangement) remains white on every face because it was never exposed to the paint. Any smaller cube lying on a face (but not on an edge or corner) gets exactly one side painted green, and these are referred to as “face-centered” cubes. The problem specifically states that the chosen cube has five white faces showing, which excludes cubes with multiple green sides (edges or corners). Consequently, the only contenders are:
The completely interior cube (which has six white faces).
One of the six face-centered cubes (each having exactly one face green).
In a random selection from the 27 cubes, the probability of picking the completely interior cube is 1/27. If that is indeed the cube chosen, then any way you put it down, all faces are white, so you would definitely see five white faces around the sides (and the sixth one below is also white).
Alternatively, if one of the six face-centered cubes is picked (probability 6/27), it has exactly one green face. To observe five white faces in view, the single green face must be the one on the bottom (i.e., the one we do not see). There are 6 possible orientations for a cube in space, and only 1 of these orientations places the green face downward, so the chance of that event (given that a face-centered cube has been chosen) is 1/6.
By summing up these two cases, we get the overall probability of seeing five white faces on the chosen cube. Once we know the cube is showing five white sides, it is either the all-white interior cube or the face-centered cube oriented with its green side hidden. Using conditional probability (Bayes’ rule), we calculate how likely it is that our picked piece is actually the fully white cube (which would guarantee the bottom is also white). The final number comes out to be 1/2.
From a more combinatorial perspective, this outcome aligns with the fact that there are equally many “ways” (when considering orientation) to get five white faces from the interior cube (which always yields five visible white faces no matter how it is placed) versus from any of the six face-centered cubes (which each only match that appearance in one out of six orientations). Adding them all up yields a ratio of 1:1, implying a 50% chance that the bottom face is white given that you already see five white faces.
Potential Follow-up Questions
Why can’t a corner piece or an edge piece ever show five white faces?
Any corner piece has three green faces, while any edge piece has two green faces. Therefore, at best, a corner piece could show three white faces, and an edge piece could show four white faces. Neither of those can reach the condition of having five white visible faces. Hence, the only possibilities are the single interior cube (all white) or a face-centered cube (exactly one green face).
How can we verify this with a more brute-force or enumerative approach?
One could label each of the 27 cubes based on its position within the 3×3×3 structure. By enumerating all possible cubes, you would see:
1 interior cube with 0 green faces.
6 face-centered cubes with exactly 1 green face.
12 edge cubes with exactly 2 green faces.
8 corner cubes with exactly 3 green faces.
For each cube type, you could count how many orientations yield five white faces visible. The interior cube has 6 possible orientations, all yielding 5 visible white faces. Each face-centered cube has 6 orientations, but only 1 orientation hides the green face on the bottom. Edge and corner cubes can never have five white faces at once. Summing up the counts and normalizing by 27×6 (the total ways to pick and orient any small cube) confirms the same probability of 1/2 for the bottom face being white.
Does the painting pattern matter if the paint were applied before slicing?
The painting pattern described assumes a uniform paint application on all six faces of the original large cube. This means each outer face ends up uniformly green. If the painting were done in a different pattern (e.g., stripes, random splatters), the counts of green faces for each smaller cube might differ. Our probability analysis hinges on knowing exactly how many smaller cubes have 0, 1, 2, or 3 painted sides. A different painting pattern would need a new breakdown of how many faces each smaller cube has painted and with what probability those are oriented hidden or visible. But under the scenario given, each face-centered piece has exactly one green face, edge pieces have two, corners have three, and the center piece has zero, so the problem’s solution is consistent for uniform painting on each of the six faces.
Could we solve this problem using the idea of conditional probability directly, without enumerating all cases?
Yes, one can directly invoke conditional probability. If B is the event “5 visible faces are white,” and A is the event “the cube is the completely internal cube,” we want P(A∣B). We compute P(B) by summing over all ways B can occur (interior cube or face-centered cube oriented correctly), then P(A∩B) is just the probability that you selected the interior cube and you see 5 white faces (which is certain if that cube is chosen). Dividing yields the same result of 1/2. This direct approach is essentially an application of Bayes’ theorem, though it is easiest to illustrate in steps by enumerating which smaller cubes can yield five visible white faces.
Below are additional follow-up questions
If the cube was a 4×4×4 (or larger N×N×N), how would the analysis change?
To apply the same reasoning about “5 visible faces white,” you would proceed by figuring out exactly which smaller cubes can ever show N−1 faces white (for 3×3×3, that was 5 out of 6). You then calculate how many orientations lead to that appearance, and from that, how likely the bottom face is white given that so many faces appear white. For large N, you’d have more interior cubes (all faces white) but also more face-centered cubes (one face green). The final probability that the unseen face is white, conditional on seeing a certain number of white faces, would be determined by extending the same logic of conditional probability and orientation counting. The arithmetic is straightforward but more involved in enumerating the new counts of fully interior cubes versus single-painted cubes.
What if the paint was applied after slicing the big cube into smaller ones?
If the big cube was already cut into the smaller cubes before painting, each small cube would have its own faces painted individually. Under that scenario, whether a small cube ends up with zero, one, two, or three green sides depends on how the painter chooses to color them. This would break the nice uniform pattern we rely on in the standard puzzle, where corners always have exactly three painted faces, edges always have exactly two, face-centers exactly one, and the interior has zero. You’d need to know the distribution of how many smaller cubes ended up with each count of green faces and how likely they are to appear with five white faces visible.
Furthermore, the probability that a particular face of a small cube gets painted might no longer be the same across all cubes, since the painting is done by direct contact on each small cube rather than by painting the large surface and slicing afterwards. That distribution would have to be separately computed or given, and the puzzle’s straightforward logic might not apply unless you replicated the exact same painting conditions in some controlled manner.
If we consider randomizing both the selection of the small cube and its orientation, how do we confirm the denominator for our probability?
When we specify that a cube is chosen “at random,” typically we interpret it as choosing uniformly from the 27 small cubes, each with equal probability. If we then set the cube down in “a random orientation,” we often consider all 6 orientations to be equally likely. Thus, the total sample space effectively becomes 27×6=162 equally likely outcomes when we consider the choice of cube and the orientation.
To confirm the denominator of 162, one ensures there is no bias either in selecting the cube or in orienting it. In many practical or physical settings, orientation might not actually be uniform, and selection might have some unspoken bias. If any bias existed (for example, the corner pieces are easier to pick up from a pile in real life), the denominator for a purely theoretical approach wouldn’t match the actual real-world picking distribution. In an interview or exam setting, the assumption is that each small cube is equally likely to be chosen and placed in any orientation with equal probability, so the denominator of 162 is indeed the correct count of possible “(cube, orientation)” pairs.
Could the chosen small cube have some hidden partial visibility that contradicts the puzzle’s assumption?
In a real-world scenario, if the cube is slightly tilted, or we have a viewpoint that can partially see underneath, it might give us partial information about whether the “bottom” face is green or white. If even a sliver of green is visible, the puzzle’s condition “five faces are white” would be invalidated because we’d see some green. Similarly, if a corner of the bottom face is visible and we see white, that changes the probabilities since we now have partial knowledge about the bottom side.
The puzzle’s assumption is that we see exactly five faces in full (and all appear white) and zero information about the sixth face. In a real-world setting, ensuring truly no glimpse of the bottom face can be tricky. A common pitfall in applying these probability puzzles to tangible objects is that often the visual perspective offers partial knowledge that changes the conditional probabilities. The puzzle’s pure approach presumes a perfect arrangement where exactly five faces are visible and verified white, and the sixth face is completely hidden with no partial clue.
Could the bottom face be something other than green or white, if, for instance, there was a different painting scheme?
In the original puzzle, there are only two colors involved: green paint on the outer faces and white on the inside. However, if a puzzle introduced multiple colors or if certain smaller cubes were painted differently for any reason (e.g., different color per face), the logic must be adapted. You would systematically list how many faces of each color are possible for each cube type, then figure out how many orientations yield the “five faces of color X” scenario. In principle, the reasoning is the same: find the set of cubes that can exhibit the observed pattern, compute how often that pattern arises, and then find the fraction of those cases that correspond to the bottom face being the color of interest.
One subtle point is that mixing more than two colors can complicate the enumeration. For example, you might have corner pieces with three differently colored faces. Then even if you see five white sides, the hidden side could be red, blue, or green, requiring a more detailed breakdown of possibilities.
How do we generalize the “bottom is white” question to something like “what is the probability the hidden face has color C” given the five faces we observe?
The logic used here is a straightforward conditional probability framework. You define:
A: event “the hidden face is color C.”
B: event “the other observed faces (some number k out of 6) have a specified color pattern.”
You compute P(A∩B) by summing over all cubes that can produce event B and also have color C on the hidden face, factoring in orientation probabilities.
This approach can handle any combination of observed colors on the visible faces and any question about the hidden face. The subtlety is making sure you correctly account for how many orientations yield the observed pattern for each type of smaller cube in the puzzle.
If we introduce a random variable representing the number of green faces we see, how could we approach the problem?
Consider a random variable X: the number of green faces observed among the 5 visible sides. In our puzzle, we specifically look at the situation X=0 (meaning we see 0 green among the 5 visible faces, i.e., all 5 are white). One could try to find P(X=0) directly by enumerating for each type of smaller cube:
Probability of picking that type of cube (corner, edge, face-center, interior).
Probability that when placed in a random orientation, none of the 5 visible faces is green.
That directly yields P(X=0). If we define Y as an indicator for the bottom face being white, then P(Y=1∣X=0) is the probability we want. This random-variable perspective is just a formal restatement of the conditional probability approach used, but it sometimes helps in an interview to show you can frame it as a standard random variable problem.
Are there practical reasons why some smaller cubes might be more likely to show 5 white faces than others in a real experiment?
Yes, real-world phenomena can introduce biases. For example, the interior cube might be located in such a way that it’s slightly heavier or shaped differently at the edges (maybe from the manufacturing process or small variations in the cut). This might affect how it naturally tends to rest on a surface. On the other hand, face-centered cubes might land “green-face-down” more or less often depending on friction or subtle physical differences. If any such bias exists, the probability that you pick up a cube and casually place it with 5 white faces showing might differ from the simple uniform orientation assumption.
In many puzzle or interview contexts, these physical details are considered negligible or nonexistent. However, strictly speaking, any non-uniform orientation distribution would change the denominators in the probability calculations and could shift the result away from 1/2. This is more of a caution about applying pure theoretical puzzle logic to real physical scenarios, an issue common in many puzzle-based questions.
Could we incorporate a Bayesian updating process if, for instance, we suspected a certain prior on how the cube might land?
Absolutely. Bayesian updating allows you to incorporate a prior belief about which cubes are likely to be chosen or how orientations might occur. For instance, suppose you believed that the all-white interior cube is less likely to be randomly selected because it’s physically in the middle of the stacked cubes. You might assign a prior probability smaller than 1/27 to that interior cube. When you observe “5 visible white faces,” you update your posterior probability that you actually picked the interior cube. That posterior probability may differ from 1/2. The standard puzzle assumes a uniform prior for both selection and orientation, which leads us to the clean 1/2 result. But the Bayesian methodology is flexible enough to handle any prior distribution, showing how you can generalize these sorts of puzzles to real-life contexts where uniformity is not guaranteed.