From 12572889a188506a50cb5ff31a813aa108c120b9 Mon Sep 17 00:00:00 2001 From: Gabriel Tofvesson Date: Wed, 6 Nov 2019 06:22:10 +0100 Subject: [PATCH] Remove single-element permutations --- src/dev/w1zzrd/math/Permutation.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dev/w1zzrd/math/Permutation.kt b/src/dev/w1zzrd/math/Permutation.kt index 4ce08c2..a5b41a5 100644 --- a/src/dev/w1zzrd/math/Permutation.kt +++ b/src/dev/w1zzrd/math/Permutation.kt @@ -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>()){ // Deduplicate transpositions insert, acc -> acc.firstOrNull { @@ -47,4 +48,4 @@ class Permutation { return elements } -} \ No newline at end of file +}