The Chomsky algorithm performance could be improved further by storing swaps found in previous iteration.
Currently, the longest swap is sought in each iteration whilst the rest is dismissed. Instead, at least the second longest swap should be preserved (the first one is already accepted!), checked for validity (it may be invalid if it overlaps with the accepted swap) so in the next iteration it will be longest swap to begin with.
This idea can be advanced by keeping a collection of possible swaps sorted by length and passed through iterations.
The Chomsky algorithm performance could be improved further by storing swaps found in previous iteration.
Currently, the longest swap is sought in each iteration whilst the rest is dismissed. Instead, at least the second longest swap should be preserved (the first one is already accepted!), checked for validity (it may be invalid if it overlaps with the accepted swap) so in the next iteration it will be longest swap to begin with.
This idea can be advanced by keeping a collection of possible swaps sorted by length and passed through iterations.