From d31b76bc4367183bdf97790552241c00768b8323 Mon Sep 17 00:00:00 2001 From: Eric Moyer Date: Sun, 29 Jul 2018 13:59:17 -0400 Subject: [PATCH] Fix bug in intersection Without this fix, there is an error when one interval is contained in the other. ``` Interval(4, 7).intersection(Interval(5, 6)) ``` returns ``` Interval(5, 7) ``` But it should return ``` Interval(5, 6) ``` --- recipes/Python/576816_Interval/recipe-576816.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/Python/576816_Interval/recipe-576816.py b/recipes/Python/576816_Interval/recipe-576816.py index 11fe0ca22..a095dda80 100644 --- a/recipes/Python/576816_Interval/recipe-576816.py +++ b/recipes/Python/576816_Interval/recipe-576816.py @@ -50,7 +50,7 @@ def intersection(self, other): other, self = self, other if self.end <= other.start: return Interval(self.start, self.start) - return Interval(other.start, self.end) + return Interval(other.start, min(self.end, other.end)) def hull(self, other):