CoTe/구현

[이코테] 욍실의 나이트

TheSole 2023. 4. 18. 15:22

# 현재 위치
input_data = input() # a1
row = int(input_data[1]) # 1
column = int(ord(input_data[0])) - int(ord("a")) +1 # 1

# 이동할 수 있는 8가지 방향
steps = [(-2, -1), (-1, -2), (1, -2), (2, -1), (2, 1), (1, 2), (-1, 2), (-2, 1), ]

#8가지 방향에 대해 각 위치로 이동이 가능한지 확인
results = 0
for step in steps:
  next_row = row + step[0]
  next_column = column + step[1]
  # 이동하고자 하는 위치 확인
  if next_row >= 1 and next_row <= 8 and next_column >= 1 and next_column <= 8:
    results += 1

print(results)