Manually summing a Cubically cube's faces is tedious and time-consuming, sorta like writing code in Cubically itself.
In Most efficient cubifier, I asked you to translate ASCII to Cubically source. One of the answers there uses a cube initialization sequence and then modifies the resulting cube based on the sums of the pre-initialized cube. This method has been used in many Cubically-related programs since. When testing a new initialization sequence, one has to add up all the values on all the faces, which usually takes two or three minutes.
Your task is to automate this process for us!
You will take two inputs, an integer
n and a string
c. These may be read from command line arguments, function arguments, standard input, a file, or any combination of those.
c will be a Cubically memory cube of size
n as pretty-printed by the interpreter.
The Cubically interpreter dumps its cube to STDERR upon program termination, formatted nicely for simple viewing. Run an empty program in the Cubically interpreter and open the debug section to see the cube dump of an initialized cube. Add an argument
4 to see a 4x4x4, or
5 to see a 5x5x5, etc.
n is 3,
c will follow this format (the integers will be variable):
000 000 000 111222333444 111222333444 111222333444 555 555 555
Spaces, newlines, and all. If
n is 4,
c will look like this (also with variable integers):
0000 0000 0000 0000 1111222233334444 1111222233334444 1111222233334444 1111222233334444 5555 5555 5555 5555
Your program will output six integers. The first integer will be the sum of all the numbers on the top face.
000 000 top face 000 111222333444 left, front, right, and back faces, respectively 111222333444 111222333444 555 555 bottom face 555
The second integer will be the sum of the left face, the third the front, the fourth the right, the fifth the back and the sixth the bottom.
n was 3 and
c was this:
242 202 242 000131555313 010121535343 000131555313 424 454 424
Your program would output
20 1 14 43 24 33.
- The output integers must be delimited by non-integer characters. You may also choose to return an array.
- You may assume that the input is correct -
nis an integer and
cis a cube from Cubically's debugging output. So if
foo bar, your program could break and still be valid.
- Your program only needs to work for
n > 1and
n < 1260. It may (attempt to) handle larger or smaller cube sizes, but it is not necessary.