Related tags:
math-for-computer-scienceA cube is painted with some colour on all faces. Now, we cut it into 1000 small cubes of equal size. How many small cubes are not painted?
One basic approach is to count the number of painted small cubes and subtract it from the total number of small cubes. Note: While solving such questions, the most important part is to visualise the cube.
If we visualise the large cube, all smaller cubes will have at least one face facing inside. So none of the smaller cubes will have all faces painted. On the other side, the maximum number of faces of the larger cube that intersect at a point = 3 (at the corners). So, the smaller cubes can have a maximum of 3 faces painted. In other words, there are three types of painted small cubes.
These smaller cubes are located at the corners of the large cube. The number of smaller cubes with 3 faces painted = The number of corners in the larger cube = 8.
To find the number of smaller cubes with only 2 faces painted, we need to consider the cubes where 2 faces of the larger cube meet, i.e. the edges. So these smaller cubes are positioned on the edges of the large cube.
Remember, each edge includes the smaller cubes present at the corners as well, which are painted on 3 sides. So we need to remove those 2 cubes from the number of cubes on each edge. So the number of smaller cubes with 2 faces painted at each edge = n — 2 (Here n is the length of each side of the cube).
Overall, there will be 12 such edges on the larger cube. So the number of smaller cubes with 2 faces painted = 12*(n — 2) = 12 * 8 = 96. (Here n = 10).
These smaller cubes are located at the face of the larger cube, excluding the cubes at corners and edges. At each face, the number of such cubes = (n — 2) * (n — 2). There are 6 faces of larger cubes, so the total number of smaller cubes with one face painted = 6 * (n — 2) * (n — 2) = 6 * 8* 8 = 384.
From the above analysis, total number of painted cubes = 8 + 12*(n — 2) + 6 * (n — 2) * (n — 2) = 8 + 96 + 384 = 488. The number of cubes not painted = 1000 – 488 = 512.
In n x n x n cube, if we remove the outer layer of all 1 x 1 x 1 painted small cubes, then the dimensions of the hidden cube (not painted) will be (n — 2) x (n — 2) x (n — 2). So number of small 1 x 1 x 1 cubes not painted = (n — 2)³ = 8³ = 512.
Suppose we have a cuboid of dimension a*b*c painted on all sides which is cut into smaller cubes of dimension 1*1*1. Then:
Enjoy learning, Enjoy mathematics!
Just like programming, math is one of the core parts of learning data structures and algorithms. We mainly use math to analyse efficiency of various algorithms. But sometimes, the problem itself contains mathematical property or requires some mathematical insight to find a solution.
The summation formulas are used to calculate the sum of the sequence. In this blog, we have discussed the visual proofs: the sum of numbers from 1 to n (arithmetic series), the sum of infinite geometric series, the sum of squares of numbers from 1 to n, etc.
Given a positive integer n, write a program to check if the number is prime or not. A number n > 1 is said to be a prime number if 1 and n are its only factors. In other words, a prime number is a number that is divisible only by two numbers itself and one.
Given two non-negative integers, m and n, we have to find their greatest common divisor or HCF. It is the largest number, a divisor of both m and n. The Euclidean algorithm is one of the oldest and most widely known methods for computing the GCD of two integers.