Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A = [
- [0,0,0,0,0,0,0,0],
- [0,1,1,1,1,0,0,0],
- [0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0],
- [0,0,0,1,1,1,1,0],
- [0,0,0,0,0,0,0,0]
- ]
- def pos(x, y):
- return min(x, y) >= 0 and max(x, y) < 8
- def check(si, sj):
- B = [[A[i][j] for j in range(8)] for i in range(8)]
- B[si][sj] = 1
- while True:
- if pos(si + 1, sj) and B[si + 1][sj] == 0:
- si += 1
- elif pos(si, sj + 1) and B[si][sj + 1] == 0:
- sj += 1
- elif pos(si - 1, sj) and B[si - 1][sj] == 0:
- si -= 1
- elif pos(si, sj - 1) and B[si][sj - 1] == 0:
- sj -= 1
- else:
- break
- B[si][sj] = 1
- return sum([sum(r) for r in B]) == 64
- k = 0
- for i in range(8):
- for j in range(8):
- if A[i][j] == 0 and check(i, j):
- print(i, j)
- k += 1
- print('Ответ', k)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement