Assign the numbers 0 through 7 to the 8 vertices of a cube in any way you want. Exactly one number must be assigned to each vertex.
For example, your vertices might be assigned like this:
3-----1 /| /| 4-----2 | | | | | | 5---|-0 |/ |/ 6-----7
Write a program that takes in an integer from 0 to 5. Each of these 6 numbers is associated with exactly one face of your cube in any way you like. When one of these numbers is input, the 4 vertex numbers of the associated face must be printed to stdout in a 2×2 square of digits. The face is to be viewed straight on from outside the cube. All 4 face rotations are valid.
For example, if 0 is associated with the front face of the example cube above, then this would be a valid output for input
The face may be viewed at any 90° rotation, so these are also valid:
This output (and its rotations) are not valid, as they are viewed from the wrong side of the face:
The same idea applies to all other faces. e.g. if 1 is associated with the back face, then input
1 might produce output
31[newline]50 would be invalid).
So the real challenge is choosing your vertex numbers and rotations such that translating the input into its 4 vertex numbers is easy and short.
The shortest code in bytes wins. Tiebreaker is earlier post. (Handy byte counter.)
- You may write a function instead of a program. It should take an integer from 0 to 5 and print or return the 2×2 digit grid string.
- Take input from stdin, command line, or function arg. You may assume input is valid.
- The output may optionally have a trailing newline.
- Be sure to tell us the vertex and face numbers you chose.