Python/이것이 취업을 위한 코딩 테스트다(with 파이썬)
구현 - 왕실의 나이트
sophia02
2022. 6. 26. 21:15
n = input()
r = int(n[1])
c = int(ord(n[0])) - 96
d = [(-2, -1), (-1, -2), (1, -2), (2, -1), (2, 1), (1, 2), (-1, 2), (-2, 1)]
dap = 0
for direction in d:
n_r = r + direction[0]
n_c = c + direction[1]
if n_r >= 1 and n_r <= 8 and n_c >= 1 and n_c <= 8:
dap += 1
print(dap)