summaryrefslogtreecommitdiffstats
path: root/1.py
diff options
context:
space:
mode:
authortanyaionova <isaqtm@gmail.com>2019-11-21 22:18:04 +0300
committertanyaionova <isaqtm@gmail.com>2019-11-21 22:18:04 +0300
commit013924d56da2eef1d40f06e43f735b406fe2e2b1 (patch)
tree7113497b9915998e83d6a72cce0cd4c2606b7e72 /1.py
parent275a6f805ecd7263bb4a8e0d495a19d237ee2f4d (diff)
downloadalg2-013924d56da2eef1d40f06e43f735b406fe2e2b1.tar.gz
Add first task
Diffstat (limited to '1.py')
-rw-r--r--1.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/1.py b/1.py
new file mode 100644
index 0000000..d920667
--- /dev/null
+++ b/1.py
@@ -0,0 +1,26 @@
+from libsolve import Permutation
+from itertools import permutations
+
+PRINT_LATEX = False
+
+# (1 2 5 8 3 7 6)(4)
+rhs = Permutation([1, 4, 6, 3, 7, 0, 5, 2])
+
+# (2 8 5 7 3 6 4)(1)
+lhs = Permutation([0, 7, 5, 1, 6, 3, 2, 4])
+
+for perm in permutations(range(8), 8):
+ p = Permutation(perm)
+
+ id = list(range(8))
+ right = rhs.apply(id)
+ left = p.apply(lhs.apply(p.apply(id)))
+ if left == right:
+ if PRINT_LATEX:
+ print('\\begin{pmatrix}', end='')
+ print(*range(1, 9), sep=' & ', end='')
+ print(*map(lambda i: f'{i + 1}', p.perm),
+ sep=' & ',
+ end='\\end{pmatrix}\\\\\n')
+ else:
+ print(p.perm)