Painted Cube Puzzle

Here is a new painted cube puzzle. If you like this one, there’s two earlier variants: Painted Cube Puzzle #1, and Painted Cube Puzzle #2.

Puzzle

You have a collection of white unit cubes which you connect together to make a solid larger cube. Then, an unknown number of the sides of this larger cube are sprayed with red paint. After the paint has dried, the larger cube is deconstructed back into a pile of unit cubes. After deconstruction, you count and find that 240 of the small cubes have paint on exactly one face. How many of the unit cubes will you find with red paint on two faces?
How many of the unit cubes will you find with red paint on two faces?

Solution

The first problem to solve is determining how big the larger cube is.
Paint could have been applied to anywhere from [1-6] sides of the large structure. The catch is that, when painting multiple sides, it matters if the painted sides share a common edge. If they do, cubes on this common edge will received more than one dose of paint (two doses on an edge, and three if a corner). Unit cubes with more than one side painted do not qualify as one of the 240 cubes painted only on one side.

Let me count the ways

Without loss of generality, there are nine possible configurations of painting [1-6] sides of a cube.
1. One face painted.
2. Two, opposite, faces painted.
4. Three faces painted (that don’t meet in a corner).
5. Three faces painted (that meet in a corner).
6. Four faces painted (with two opposite sides clean).
7. Four faces painted (with two adjacent sides clean).
8. Five painted faces.
9. Six painted faces.
Some of these can be hard to visualize, so I’ve drawn a net for each example, and for each, derived a formula for the number of single painted cubes that would be generated for that configuration (remember, common edges don’t count, and neither do common corners). In the diagrams below, the red shows the paint, but what we want to count is just the cubes that are singly painted!

#1 One face painted
SP = n×n

#2 Two, opposite, faces painted
SP = 2×(n×n)

SP = 2×n×(n-1)

#4 Three faces painted (no corner)
SP = [2×n×(n-1)] + [n×(n-2)]

#5 Three faces painted (corner)
SP = 3×(n-1)×(n-1)

#6 Four faces painted (opposite clean).
SP = 4×n×(n-2)

#7 Four faces painted (adjacent clean)
SP = [2×(n-1)×(n-2)] + [2×(n-1)×(n-1)]

#8 Five painted faces
SP = [(n-2)×(n-2)] + [4×(n-1)×(n-2)]

#9 Six painted faces
SP = 6×(n-2)×(n-2)

These formulas done, we can calculate the number of singly painted cubes for an increasing size of the larger cube. Here is a table of the results (we don’t need to go any higher than 16×16×16 as all cubes larger than this have ≥240 single painted unit cubes; irrespective of the number of painted faces). Each row shows an increasing value for n, and each column represents the class above.
#1#2#3#4#5#6#7#8#9
n=1100000000
n=2484430200
n=3918121512121296
n=4163224322732302824
n=5255040554860565754
n=6367260847596909696
n=7499884119108140132145150
n=864128112160147192182204216
n=981162144207192252240273294
n=10100200180260243320306352384
n=11121242220319300396380441486
n=12144288264384363480462540600
n=13169338312455432572552649726
n=14196392364532507672650768864
n=152254504206155887807568971,014
n=162565124807046758968701,0361,176
As you can see, there is a distinct answer for 240 singly painted cubes, and this occurs where n = 9 (with four painted sides and two, adjacent, non-painted sides). The larger cube must have a dimension of nine.
The larger cube must have a dimension of nine.

Calculating

Now that we have the dimensions of the larger cube, all we need to do is count the unit cubes that are painted on two sides.
We need to be careful so as not to double, or triple, count the number of two painted cubes. The double painted cubes occur on the edges (but not common corners).
Double Painted = [2×(n-1)] + [2×(n-1)] + [n-2]
Double Painted = 16 + 16 + 7 = 39
There will be 39 unit cubes painted on two sides.
A picture paints a thousand words (see what I did there?). Here is a net of the solution. The single painted cubes are colored red, the doubly painted cubes are colored green, and the triply painted cubes in the common corners are painted pink. I’ve labeled each double painted cube with a distinct number to disambiguate as they appear in two places on the net when un-folded.