TopCoder problem "DistinctDice" used in TCHS SRM 12 (Division I Level Two)



Problem Statement

    

Let's consider a standard six-sided die. Each side contains a distinct number between 1 and 6. We can represent a single die as a sequence of 6 digits in the following order: the number on its top side, bottom side, left, right, front and back sides. You are given a String[] givenDice, each element of which represents a single die in the described format.

Your task is to determine the number of distinct dice in givenDice. Two dice are considered equal if they can be rotated in such a way that the numbers on the corresponding sides are all equal.

 

Definition

    
Class:DistinctDice
Method:getDistinct
Parameters:String[]
Returns:int
Method signature:int getDistinct(String[] givenDice)
(be sure your method is public)
    
 

Constraints

-givenDice will contain between 1 and 50 elements, inclusive.
-Each element of givenDice will contain exactly 6 characters.
-Each character of each element of givenDice will be a digit between '1' and '6', inclusive.
-Within each element of givenDice, all characters will be distinct.
 

Examples

0)
    
{"123456","654321"}
Returns: 1
1)
    
{"145326","154236","216543"}
Returns: 3
2)
    
{"165324"}
Returns: 1
3)
    
{"546231", "245631", "531462", "524631",
 "614235", "415623", "423651", "316254",
 "432165", "316452", "135426", "643512"}
Returns: 10

Problem url:

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

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10064&pm=6512

Writer:

Pawa

Testers:

PabloGilberto , brett1479 , Olexiy

Problem categories:

Simulation, Sorting