Last active
January 4, 2016 00:19
-
-
Save cocodrips/8540727 to your computer and use it in GitHub Desktop.
SRM 605 Div2 med
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 AlienAndGame: | |
| def getNumber(self, board): | |
| arr = [] | |
| for r in board: | |
| arr.append(list(r)) | |
| rlen = len(arr) | |
| clen = len(arr[0]) | |
| N = min(rlen, clen) | |
| for n in range(1, N+1)[::-1]: | |
| for r1 in xrange(rlen - n): | |
| for c1 in xrange(clen - n): | |
| OK = True | |
| for r in xrange(r1, r1 + n + 1): | |
| first = arr[r][c1] | |
| for c in xrange(c1, c1 + n + 1): | |
| if arr[r][c] != first: | |
| # print arr[r] | |
| OK = False | |
| break | |
| if not OK: | |
| break | |
| if OK: | |
| return (n+1) * (n+1) | |
| return 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment