That's very easy, it's a function of an XYZ loop....
You would be actually doing a marching cubes kind of logic, and an ISOsurface logic for a spherical volume.
The first result is this programming query (in metacode):
var cubecount:
ForLoop(x,y,z){
If space(x,y,z) corresponds to DistanceFunction(x,y,z) == 1;
Then cubecount +=1:
question 2 is the same using >=1
For a sphere on zero of radius 1. (distancefunction is xposvectormagnitude, same thing if the sphere is origin is 0; otherwise the sphere pos equation is for the xyz loop is:
This code makes a 3d printable off axis voxel ball if you want:
num = 45.9874;
for (x =[-num-5:num+5])
{
for (y =[-num-5:num+5])
{
for (z =[-num-5:num+5])
{
if ((x+1.24)*(x+1.24)+(y+1.66)*(y+1.66)+(z+1.88)*(z+1.88)<=num)
translate([x,y,z])
cube(1);
}
}
}
https://www.thingiverse.com/thing:3075040
This answer requires some spatial examples, so I think it will be better if I generalize the case of a simple cube, which can be applied to all possible situations.
As you said, the total area covered by the paint in a cube with lenght $a$ is equal to:
$$
S_{\mathrm{ext}}=6\cdot a^2
$$
But then the division into $27$ cubes with lenght $1/3$ of the original gives the new surface area, greater than the original because new slices prodce more internal surface; so now the total surface is expressed by:
$$
S_{\mathrm{tot}}=27\cdot 6\cdot (a/3)^2=\frac{27\cdot 6}{9}\cdot a^2=3\cdot 6\cdot a^2=3S_{\mathrm{ext}}
$$
Now think about a Rubik's Cube, with only the cubes facing the outside are painted: since you know that the total amount of paint occupies the external surface $S_{\mathrm{ext}}$, then to know the surface not covered in paint you have to simply subtract to the total sliced surface $S_{\mathrm{tot}}$ the external one:
$$
S_{\mathrm{unpaint}}=S_{\mathrm{tot}}-S_{\mathrm{ext}}=3S_{\mathrm{ext}}-S_{\mathrm{ext}}=2S_{\mathrm{ext}}=12\cdot a^2
$$
Now you have basically derived the sum of the internal surface of every little cube, because the sum of the external is nothing more than the total covered in paint, or $S_{\mathrm{ext}}$ (with the Rubik's Cube case, the only cubes coloured).
EDIT: If the number of slices is not defined, it is generalized to a single parameter $n\in \mathbb{N}$, then the new surface tends to be greater as $n$ gets larger.
Let's assume that one cut is repeated on every edge of the cube, so if an edge is divided in three (with two slices), then the number of cubes created is expressed as follows:
$$
N_{\mathrm{cubes}}=(n+1)^3
$$
So if I "slice" a cube for every edge once ($n=1$), I get $N_{\mathrm{cubes}}=(2)^3=8$ little cubes.
The surface of each sub-cube is expressed by:
$$
S_{\mathrm{sub-cb}}=6\cdot\left(\frac{a}{n+1}\right)^2
$$
Then the total surface is expressed as th single one multiplied by the total number of sub-cubes created $N_{\mathrm{cubes}}$:
$$
S_{\mathrm{tot}}=(n+1)^3\cdot 6\cdot\left(\frac{a}{n+1}\right)^2=(n+1)\cdot 6\cdot a^2=(n+1)\cdot S_{\mathrm{ext}}
$$
Now, applying the same deduction as before, the surface not covered with paint is given by a simple subtraction between the total surface and the ponly painted one, which is the external one:
$$
S_{\mathrm{unpaint}}=S_{\mathrm{tot}}-S_{\mathrm{ext}}=(n+1)\cdot S_{\mathrm{ext}}-S_{\mathrm{ext}}=n\cdot S_{\mathrm{ext}}
$$
Now remember that the parameter $n$ is the number of slices, and not the sub-cubes created; as your previous example, the slices were $2$, and so this number appeared inside the final result.
Best Answer
I think you are given the image of a box (with no face at the top), where the sides and bottom have only length and width, but no depth (in an ideal topless rectangular cube.
For example, if we align the a $10 \text{cm } \times 10 \text{cm } \times 10\text{cm }$ ideal box (with no top in the $z = 10$ plane, with one corner at the origin, and the bottom and sides that share that corner, along the x y z axes, the first octant, with the top open, point $(2, 3, 0)$ on the "bottom of the box" is the same point on that's on the bottom of the inside of the box.
So taking the surface area, there is really no "outside" or "inside" area. We exclude, unless given, depth of wood (if the box is wooden) or even cardboard (accordingly).
So the surface area of such an "ideal" box (rectangular cube) is the sum of the area of the bottom side, plus the sum of the areas of each of four sides.
In the example I give above, the surface area is $10 \times 10 \times 5 = 500 \text{cm}^3$.
Note, unless told the thickness of a box's bottom and sides, we take that the "external" side is identical to the "internal side". So count only the area of the five sides, summed.
If, on the other hand, you are given that the open-topped box (say a wooden box), with width/length of the bottom, and height/length of the sides, and the thickness of the wood, or metal, or cardboard (say 2mm), then we'd need to take the surface area of the inside, which would necessarily be less than the external surface area (also exposed to air), add them both, and you'd need to also count the area of the upper rim four times the thickness \times the length of one side of the box.
In your example of a solid cube with solid cylinder removed (say drilled out from top to bottom): Then you'd need to sum the surface area of the 6 sides, prior to drilling, and after drilling depending on the radius $r$ of the open circles, on top and bottom, you'd need to subtract $2 \times \pi r^2$ and then you'd need to add $2\pi rx,$ (where $x$ is the height of one of the sides,
The difference between the two is how we define a box, and whether we are to take it ideal (no thickness of the walls/sides of the box) which we must do unless provided with the added dimension of thickness of the walls.