Remove single-element permutations

This commit is contained in:
Gabriel Tofvesson 2019-11-06 06:22:10 +01:00
parent ade18b5ccf
commit 12572889a1

View File

@ -22,6 +22,7 @@ class Permutation {
*/
operator fun times(perm: Permutation)
= Permutation(this(*perm(*orderedElements)).zip(orderedElements) // Generate transpositions
.filterNot{ it.first == it.second }
.foldRight(ArrayList<Pair<Char, Char>>()){ // Deduplicate transpositions
insert, acc ->
acc.firstOrNull {