@anonymous/

NecessaryGlamorousPi

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
def mult_perm(x, y):
	out_perm = []
	limit = len(y)
	for i in range(limit):
		out_perm.append(x[y[i]])
	return out_perm

def rev_perm(x):
	limit = len(x)
	out_perm = [None] * limit
	for i in range(limit):
		out_perm[x[i]] = i
	return out_perm

#x^2y^-1
def sol1(x, y):
	return mult_perm(mult_perm(x, x), rev_perm(y))


print(mult_perm([1, 2, 0], [1, 2, 0])) # -> [2, 0, 1]
print(rev_perm([0, 1, 2])) # -> [0, 1, 2]
print(sol1([1, 2, 0], [0, 1, 2])) # -> [2, 0, 1]