Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.48 KB | None | 0 0
  1. s = []
  2. a = [[1 for j in range(8)] for i in range(8)]
  3. for i in range(8):
  4.     s.append(input())
  5. for i in range(8):
  6.     for j in range(8):
  7.         if s[i][j] == 'B':
  8.             a[i][j] = 0
  9.             x = i - 1
  10.             y = j - 1
  11.             while x >= 0 and y >= 0 and s[x][y] == '*':
  12.                 a[x][y] = 0
  13.                 x -= 1
  14.                 y -= 1
  15.             x = i - 1
  16.             y = j + 1
  17.             while x >= 0 and y < 8 and s[x][y] == '*':
  18.                 a[x][y] = 0
  19.                 x -= 1
  20.                 y += 1
  21.             x = i + 1
  22.             y = j + 1
  23.             while x < 8 and y < 8 and s[x][y] == '*':
  24.                 a[x][y] = 0
  25.                 x += 1
  26.                 y += 1
  27.             x = i + 1
  28.             y = j - 1
  29.             while x < 8 and y >= 0 and s[x][y] == '*':
  30.                 a[x][y] = 0
  31.                 x += 1
  32.                 y -= 1
  33.         if s[i][j] == 'R':
  34.             a[i][j] = 0
  35.             x = i - 1
  36.             while x >= 0 and s[x][j] == '*':
  37.                 a[x][j] = 0
  38.                 x -= 1
  39.             x = i + 1
  40.             while x < 8 and s[x][j] == '*':
  41.                 a[x][j] = 0
  42.                 x += 1
  43.             y = j - 1
  44.             while y >= 0 and s[i][y] == '*':
  45.                 a[i][y] = 0
  46.                 y -= 1
  47.             y = j + 1
  48.             while y < 8 and s[i][y] == '*':
  49.                 a[i][y] = 0
  50.                 y += 1
  51. ans = 0
  52. for i in range(8):
  53.     ans += sum(a[i])
  54. print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement