Skip to content

Commit 0158e18

Browse files
author
Nadia Lafrenière
committed
Improvements to from_lehmer_cocode: accepts a tuple, reduces number of subtractions
1 parent 9bebc62 commit 0158e18

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/sage/combinat/permutation.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7517,12 +7517,12 @@ def from_lehmer_cocode(lehmer, parent=Permutations()):
75177517
[2, 1, 5, 4, 3]
75187518
"""
75197519
p = []
7520-
i = 1
7521-
lehmer.reverse()
7522-
open_spots = list(range(1,len(lehmer)+1))
7523-
for ivi in lehmer:
7524-
p.append(open_spots.pop(len(lehmer)-i-ivi))
7525-
i += 1
7520+
ell = len(lehmer)
7521+
i = ell-1
7522+
open_spots = list(range(1, ell+1))
7523+
for ivi in reversed(lehmer):
7524+
p.append(open_spots.pop(i-ivi))
7525+
i -= 1
75267526
p.reverse()
75277527
return parent(p)
75287528

0 commit comments

Comments
 (0)