sort with string gamma

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
def normGamma(string, gamma):
gamma = (gamma * (len(string) // len(gamma) + 1))[0:len(string)]
g = []
for i in range(0, len(gamma), 5):
g.append(int(gamma[i:i+5], 2))
normGm = [x for x in range(0, len(g))]
for i in range(0, len(g)):
minInd = 0
minNum = 33
for n in range(0, len(g)):
if g[n] < minNum:
minNum = g[n]
minInd = n
g[minInd] = 34
normGm[minInd] = i
return normGm
def sort(string, gamma):
encArr = nGamma = normGamma(string, gamma)
for i in range(0, len(nGamma)):
n = nGamma[i]
encArr[i] = string[5*n:5*n+5]
result = ""
for i in encArr:
result += i
return result