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
| # Alternative implementation of pygame.Rect that uses floats rather than integers | |
| # | |
| # Use FRect from pygame-ce instead of this! | |
| # https://pyga.me/docs/ref/rect.html | |
| # | |
| # Don't question the implementation strategy, this is perfect | |
| # Repurposed from another project of mine | |
| # Constants needed for my direct translation of SDL_IntersectRectAndLine |
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 KMP: | |
| def partial(self, pattern): | |
| """ Calculate partial match table: String -> [Int]""" | |
| ret = [0] | |
| for i in range(1, len(pattern)): | |
| j = ret[i - 1] | |
| while j > 0 and pattern[j] != pattern[i]: | |
| j = ret[j - 1] | |
| ret.append(j + 1 if pattern[j] == pattern[i] else j) |