fork(1) download
  1. f=lambda M,t=1:max(f(M[1:]),f(zip(*M)[::-1],t+1))if`t/3`in`M`else`M`.count(`t`)
  2.  
  3. F = f
  4. def f(M, t = 1, D={}):
  5. k = tuple(M) + (t,)
  6. if k not in D:
  7. D[k] = F(M,t)
  8. return D[k]
  9.  
  10. print f([(1, 1, 1, 0, 1, 1, 0, 0, 0), (1, 1, 0, 1, 1, 1, 1, 0, 0), (0, 0, 1, 1, 1, 1, 1, 1, 0), (0, 1, 1, 1, 1, 1, 1, 1, 1), (0, 0, 1, 1, 1, 1, 1, 1, 0), (0, 0, 0, 1, 1, 1, 1, 0, 0), (0, 0, 0, 0, 1, 1, 0, 0, 0)])
  11. print f([(0, 0, 0, 1, 1, 0, 0, 0, 0), (1, 1, 0, 1, 1, 0, 0, 1, 0), (1, 1, 0, 1, 1, 1, 1, 1, 0), (1, 1, 0, 0, 1, 1, 1, 0, 0), (0, 1, 0, 0, 1, 1, 1, 1, 1), (1, 1, 1, 1, 1, 1, 1, 1, 1), (1, 1, 1, 1, 0, 1, 1, 1, 0)])
Success #stdin #stdout 0.28s 9120KB
stdin
Standard input is empty
stdout
20
12