Remove single-element permutations
This commit is contained in:
parent
ade18b5ccf
commit
12572889a1
@ -22,6 +22,7 @@ class Permutation {
|
|||||||
*/
|
*/
|
||||||
operator fun times(perm: Permutation)
|
operator fun times(perm: Permutation)
|
||||||
= Permutation(this(*perm(*orderedElements)).zip(orderedElements) // Generate transpositions
|
= Permutation(this(*perm(*orderedElements)).zip(orderedElements) // Generate transpositions
|
||||||
|
.filterNot{ it.first == it.second }
|
||||||
.foldRight(ArrayList<Pair<Char, Char>>()){ // Deduplicate transpositions
|
.foldRight(ArrayList<Pair<Char, Char>>()){ // Deduplicate transpositions
|
||||||
insert, acc ->
|
insert, acc ->
|
||||||
acc.firstOrNull {
|
acc.firstOrNull {
|
||||||
@ -47,4 +48,4 @@ class Permutation {
|
|||||||
|
|
||||||
return elements
|
return elements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user