Eight corner bricks are taken out from a 5x5x5 block, which is something like below:
How many rectangular prisms of all sizes can be counted in this block?
Source: Oyun 2018 Final Exam Question
Puzzling Stack Exchange is a question and answer site for those who create, solve, and study puzzles. It only takes a minute to sign up.
Sign up to join this communityEight corner bricks are taken out from a 5x5x5 block, which is something like below:
How many rectangular prisms of all sizes can be counted in this block?
Source: Oyun 2018 Final Exam Question
Suppose we leave the corners there. Then
a rectangular prism (= cuboid) is defined by three pairs of planes, so there are $\binom{6}{2}^3=15^3=3375$ of these.
How many of these are excluded by having no corners?
A cuboid $[a,b]\times[c,d]\times[e,f]$ uses a corner iff ($a=0$ OR $b=5$) AND ($c=0$ OR $d=5$) AND ($e=0$ OR $f=5$). The number of ways to choose $(a,b)$ so that this happens is 11, so there are $11^3=1331$ of these.
[EDITED to add:]
Oops, turns out I meant 9 not 11. 01 02 03 04 05 15 25 35 45. So 729 rather than 1331, leading to a correspondingly larger final answer.
So the number of "good" cuboids is
3375 minus 1331 = 2044. [EDITED to add:] Nope, 3375-729 = 2646.
I think Gareth McCaughan has the right reasoning but a small calculation error. I'll copy his explanations here :
Suppose we leave the corners there. Then
Let's give coordinates to the cubes from 1 to 5 in length, width and height. A rectangular prism (= cuboïd) is defined by its smallest and biggest index (possibly equal) on each axis, so there are $(\binom{5}{2}+5)^3=15^3=3375$ of these.
How many of these are excluded by having no corners?
A cuboïd $[a,b]\times[c,d]\times[e,f]$ uses a corner iff ($a=1$ OR $b=5$) AND ($c=1$ OR $d=5$) AND ($e=1$ OR $f=5$). The number of ways to choose $(a,b)$ so that this happens is $9$, so there are $9^3=729$ of these.
Alternatively, by inclusion/exclusion:
There are $5 \times 5 \times 5=125$ cuboïds using the 'vanished' $(1,1,1)$ corner cube, and $8$ ways to pick a corner.
There are $5 \times 5=25$ cuboïds using the 'vanished' $(1,1,1)$ and $(1,1,5)$ cubes, and $12$ ways to pick an edge.
There are $5$ cuboïds using the four 'vanished' $(1,1,1)$, $(1,5,1)$, $(1,5,5)$ and $(1,1,5)$ cubes on any given face, and $6$ ways to pick a face.
There is $1$ cuboïd using all eight 'vanished' corner cubes.
The number of 'wrong' cuboïds is then: $(125 \times 8)-(25 \times 12)+ (5 \times 6) -1=729$
So the number of "good" cuboïds is
$3375 - 729 = \mathbf{2646}$.
A computer version in JavaScript:
<!doctype html>
<html>
<title>Cuboids</title>
<body>
<span id='out'></span><br>
<button onclick='go();'>go</button>
</body>
<script>
function go() {
var d=0;
for (let a=0;a<15;a++)
for (let b=0;b<15;b++)
for (let c=0;c<15;c++)
if ((a==0 || a==1 || a==2 || a==3 || a==4 || a==8 || a==11 || a==13 || a==14) &&
(b==0 || b==1 || b==2 || b==3 || b==4 || b==8 || b==11 || b==13 || b==14) &&
(c==0 || c==1 || c==2 || c==3 || c==4 || c==8 || c==11 || c==13 || c==14)) d++;
out.textContent=d;
d=0;
for (let a=0;a<5;a++)
for (let b=0;b<5;b++)
for (let c=0;c<5;c++)
d+=countCuboids(a,b,c);
out.textContent+=' :: '+d;
}
function countCuboids(a,b,c) {
if (a%4==0 && b%4==0 && c%4==0) return 0;
if (a%4>0 && b%4==0 && c%4==0) return (4-a)*(5-b)*(5-c);
if (a%4==0 && b%4>0 && c%4==0) return (5-a)*(4-b)*(5-c);
if (a%4==0 && b%4==0 && c%4>0) return (5-a)*(5-b)*(4-c);
if (a%4>0 && b%4>0 && c%4==0) return (5-a)*(5-b)*(5-c)-(5-c);
if (a%4>0 && b%4==0 && c%4>0) return (5-a)*(5-b)*(5-c)-(5-b);
if (a%4==0 && b%4>0 && c%4>0) return (5-a)*(5-b)*(5-c)-(5-a);
if (a%4>0 && b%4>0 && c%4>0) return (5-a)*(5-b)*(5-c)-1;
}
</script>
</html>
The first version maps $0..14$ to $1,12,123,1234,12345,2,23,234,2345,3,34,345,4,45,5$ and counts anything that has a $1$ or a $5$ in all three loop variables.
Result: 729 (=$15^3-2646$)
The second uses an explicit function to calculate the number of right, up, back cuboids from a starting cube, and sums them.
Result: 2646