Use an array of size 100,000 to keep track of each snowflake and their sum, where the sum is the total length of all arms. Sort the array by sum (either ascending or descending). Walk through the array. Only compare flakes that have the same sum. This does not guarantee that the flakes will be the same, but no two flakes can be alike unless their total lengths are equal. The comparison function should work by comparing the indexes like so: 0 0 1 1 2 2 3 3 4 4 5 5 1 0 2 1 3 2 4 3 5 4 0 5 ... etc ... 5 0 0 1 1 2 2 3 3 4 4 5 This can be done with a double-nested loop and a modulus operation on the first index. Then repeat with the second array incrementing backwards. If at any time the inside loop completes without finding any differences, the snowflake is similar. And if a similar flake is ever found, output the message and exit.