Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix bug in hull
Without this fix, hull returns the wrong result when one interval is completely contained in the other

    Interval(4, 7).hull(Interval(5, 6))

returns

    Interval(4, 6)

not the correct answer of

    Interval(4, 7)
  • Loading branch information
Eric Moyer
Eric Moyer authored Jul 29, 2018
commit f3507df005b47775927ad30e287e741489e4e010
4 changes: 1 addition & 3 deletions recipes/Python/576816_Interval/recipe-576816.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ def intersection(self, other):

def hull(self, other):
"@return: Interval containing both self and other."
if self > other:
other, self = self, other
return Interval(self.start, other.end)
return Interval(min(self.start, other.start), max(self.end, other.end))


def overlap(self, other):
Expand Down