Skip to content

Instantly share code, notes, and snippets.

@cocodrips
Last active January 4, 2016 00:19
Show Gist options
  • Select an option

  • Save cocodrips/8540727 to your computer and use it in GitHub Desktop.

Select an option

Save cocodrips/8540727 to your computer and use it in GitHub Desktop.
SRM 605 Div2 med
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