TopCoder problem "CubeNets" used in SRM 417 (Division I Level Two)



Problem Statement

    

In geometry a cube net is an arrangement of identical edge-joined squares in the plane which can be folded (along the edges) to become the faces of a cube.



In this problem you need to check if the given figure is a cube net. The given figure will be a union of six identical squares lying in the same plane and will be given to you as a String[] figure. Each element of figure will consist of '.' (dot) and '#' (sharp) characters only. A sharp represents one of the six squares, whereas a dot represents an empty space. Return "YES" if figure represents a cube net, or "NO" otherwise (all quotes for clarity).

 

Definition

    
Class:CubeNets
Method:isCubeNet
Parameters:String[]
Returns:String
Method signature:String isCubeNet(String[] figure)
(be sure your method is public)
    
 

Constraints

-figure will contain between 1 and 6 elements, inclusive.
-Each element of figure will contain between 1 and 6 characters, inclusive.
-Each element of figure will contain '.' (dot) and '#' (sharp) characters only.
-All elements of figure will contain the same number of characters.
-There will be exactly 6 '#' (sharp) characters among all the elements of figure.
 

Examples

0)
    
{"..#.",
 "####",
 "..#."}
Returns: "YES"
Here you can first fold across all the vertical edges to make the middle four squares become the down, right, up and left faces of the cube-to-be. One then finishes off the construction by folding across the remaining two edges to make the other two squares become the front and back faces of the cube.
1)
    
{"###",
 "###"}
Returns: "NO"
This is not a cube net.
2)
    
{"..#.",
"####",
".#.."}
Returns: "YES"
3)
    
{"##..",
 ".##.",
 "..##"}
Returns: "YES"
4)
    
{"####",
 "...#",
 "...#"}
Returns: "NO"

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=9942

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=13508&pm=9942

Writer:

Pawa

Testers:

PabloGilberto , Olexiy , ivan_metelsky , Xixas

Problem categories:

Math, Simulation