in reply to Comparing two arrays
Here’s another way to do it: scan the arrays to convert them to a vector using some form of “run-length encoding.” For instance, a list containing the position of the next '1' and the number of '1's that occur. Now for the magic: use a Digest algorithm of some sort ... could be CRC, SHA1, could be anything ... to convert that vector into a single value that can be used as a hash.
Actually, if you use a truly-decent message digest algorithm, like SHA1, you probably won’t have to do anything else, because one and only one vector will map to the same hash value. You have to preprocess each array one time to compute its message-digest hash, but from there on out you might not have to examine the array contents at all. A comparison of the digests ought to be sufficient. Aside from the overhead of passing through each array one time to calculate its digest, the overhead of laborious comparison ... disappears.