Skip to content

Commit

Permalink
Trac #34343: Speed up computing outside corners of partition
Browse files Browse the repository at this point in the history
Speed up the code for getting the corners of a partition.

URL: https://trac.sagemath.org/34343
Reported by: tkarn
Ticket author(s): Trevor K. Karn
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager committed Aug 29, 2022
2 parents 420bbe2 + bde6bb5 commit ad05368
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/sage/combinat/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -4027,15 +4027,12 @@ def outside_corners(self):
sage: Partition([]).outside_corners()
[(0, 0)]
"""
p = self
if p.is_empty():
p = self._list
if not p:
return [(0,0)]
res = [ (0, p[0]) ]
for i in range(1, len(p)):
if p[i-1] != p[i]:
res.append((i,p[i]))
res = [(0, p[0])]
res.extend((n, j) for n, (i, j) in enumerate(zip(p[:-1], p[1:]), start=1) if i != j)
res.append((len(p), 0))

return res

addable_cells = outside_corners # for compatibility with partition tuples
Expand Down

0 comments on commit ad05368

Please sign in to comment.