Take the following
4x4x4 cube along with a 2D view of 3 of its faces, with a common
1x1x1 cube highlighted:
The arrows represent the points of view that generated the
V3 faces drawn underneath the big cube.
Given an arrangement of some
1x1x1 cubes inside the main cube we can try and identify it with only three projections. For example, the arrangement below:
could be represented as follows:
V1 X... .... .... XXXX V2 X... X... X... X..X V3 X... X... X... XXXX
However, if we consider only projections on
V2, most of the time we can't identify uniquely the arrangement being considered.(there are arrangements that can't be uniquely identified, even with the 6 projections)
Given projections on
V2, output the minimum and maximum number of
1x1x1 cubes that an arrangement could have and still produce the projections
I'll walk you through 2 examples:
Explained example 1
V1 XXXX .... .... .... V2 X... X... X... X...
These two projections signal some directions along which there must be cubes:
and the output would be
4, 16; This is the case because both
V3 below represent valid projections on
V3a X... .X.. ..X. ...X
This is a "diagonal" pattern of cubes in the back plane, when viewed from
V3b XXXX XXXX XXXX XXXX
and this is a full face in the back plane.
Explained example 2
V1 XXXX XXXX XXXX XXXX V2 XXXX .... .... ....
These projections represent the top face of the main cube, so in this case we managed to identify the arrangement uniquely. The output in this case would be
16, 16 (or
16, see output rules below).
Your code takes the projections on
V2 as input. There are a variety of reasonable ways for you to take this input. I suggest the following to represent each projection:
- An array of length 4 with strings of length 4, two different characters to encode "empty" or "filled", like
["X...", ".X..", "..X.", "...X"]for the
- An array/string of length 16, representing the 16 squares of the projection, like
- An integer where its base 2 expansion encodes the string above; 1 must represent the
V3aabove would be
33825 = b1000010000100001.
For any of the alternatives above, or for any other valid alternative we later decide that is helpful for you guys, you can take any face in any orientation you see fit, as long as it is consistent across test cases.
The two non-negative integers representing the minimum and maximum possible number of
1x1x1 cubes in an arrangement that projects onto
V2 like the input specifies. If the minimum and maximum are the same, you can print only one of them, if that helps you in any way.
(I didn't really know how to format these... if needed, I can reformat them! Please let me know.)
XXXX .... .... ...., X... X... X... X... -> 4, 16 XXXX XXXX XXXX XXXX, XXXX .... .... .... -> 16, 16 XXXX XXXX XXXX XXXX, XXXX .... ..X. .... -> 16, 20 X..X .XX. .XX. X..X, X.XX .X.. ..X. XX.X -> 8, 16 XXXX XXXX XXXX XXXX, XXXX XXXX XXXX XXXX -> 16, 64 X... .... .... XXXX, X... X... X... X..X -> 8, 8 X..X .... .... XXXX, X... X... X... X..X -> 8, 12
This is code-golf so shortest submission in bytes, wins! If you liked this challenge, consider upvoting it! If you dislike this challenge, please give me your feedback. Happy golfing!