Created
February 9, 2018 03:53
-
-
Save jkoppel/14a54f1d513475c82ddb14cd53f8bcb2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class interval: | |
| def init(low, hi): | |
| self.low = low | |
| self.hi = hi | |
| # bad version | |
| def intersect(oth): | |
| if self.low <= oth.low: | |
| if self.hi < oth.low: | |
| return interval(0,0) | |
| elif: oth.hi <= self.hi: | |
| return self | |
| else: | |
| return interval(oth.min,self.max) | |
| elif self.hi >= oth.hi: | |
| if self.low > oth.hi: | |
| return interval(0,0) | |
| elif: oth.low >= self.low: | |
| return oth | |
| else: | |
| return interval(oth.max,self.min) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment