in reply to Speeding permutation counting

I haven't tried it, but I'd suggest the following for each string:

Use unpack to split your string into pairs, and then unpack again, this time discarding the first character (otherwise you would get only pairs where the first index is even).

Then use either your counting technique, or a hash.

And benchmark it!

Update: This posting is irrelevant since I interpreted the original question wrongly.