fork download
  1. def check(l, n):
  2. return set(i.count(1) for i in l) == {n}
  3.  
  4. Ls = [
  5. [ [0,1,1,1],[1,0,1,1],[1,1,0,1],[1,1,1,0] ],
  6. [[0,0,1,1],[1,1,1,1]],
  7. [[1,1,1,1], [1,0,1,1], [1,1,0,1], [1,1,1,0]],
  8. ]
  9.  
  10. ns = [1, 2, 3, 4]
  11.  
  12. for L, n in ((L, n) for L in Ls for n in ns):
  13. print 'The result of check(%r, %s) is: %r' % (L, n, check(L, n))
  14.  
Success #stdin #stdout 0.08s 10864KB
stdin
Standard input is empty
stdout
The result of check([[0, 1, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0]], 1) is: False
The result of check([[0, 1, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0]], 2) is: False
The result of check([[0, 1, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0]], 3) is: True
The result of check([[0, 1, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0]], 4) is: False
The result of check([[0, 0, 1, 1], [1, 1, 1, 1]], 1) is: False
The result of check([[0, 0, 1, 1], [1, 1, 1, 1]], 2) is: False
The result of check([[0, 0, 1, 1], [1, 1, 1, 1]], 3) is: False
The result of check([[0, 0, 1, 1], [1, 1, 1, 1]], 4) is: False
The result of check([[1, 1, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0]], 1) is: False
The result of check([[1, 1, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0]], 2) is: False
The result of check([[1, 1, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0]], 3) is: False
The result of check([[1, 1, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0]], 4) is: False