[BaekJoon] 1100번: 하얀 칸 (Python)
- Reference
i % 2 == j % 2
- 사실상 이 아이디어가 다임
Solution
import sys
from typing import List
def solution(board: List[str]) -> int:
answer = 0
# (i % 2 == j % 2) -> 체스판 핵심
white = 1
for i in range(len(board)):
for j in range(len(board)):
if board[i][j] == 'F' and (i % 2 == j % 2):
answer += 1
white += 1
return answer
array = []
for _ in range(8):
array.append(sys.stdin.readline().rstrip())
print(solution(array))
Leave a comment