c:\test>600418.pl This input 0 0 1 1 0 1 0 1 1 1 0 1 0 1 0 1 1 0 0 1 0 1 1 1 0 Inverted looks like this 0 : 01010 1 : 00111 2 : 11001 3 : 11101 4 : 01010 This subset can be removed from the main group: 0 : 01010 4 : 01010 c:\test>600418.pl This input 0 0 0 1 1 0 0 0 0 1 0 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 0 0 1 1 1 1 0 1 1 1 0 0 1 Inverted looks like this 0 : 00111 1 : 01010 2 : 00111 3 : 11001 4 : 11101 5 : 01010 6 : 01110 7 : 00111 This subset can be removed from the main group: 1 : 01010 5 : 01010 This subset can be removed from the main group: 0 : 00111 2 : 00111 7 : 00111