이코테) 왕실의 나이트

min:D·2022년 7월 4일
0

알고리즘 공부

목록 보기
4/10
input = input() #열행
row = int(input[1])
column = (int(ord(input[0])) - int(ord('a'))) + 1

move = [(2, -1), (2, 1), (-2, 1), (-2, -1), (-1, 2), (-1, 2), (1, 2), (1, -2)] # (row, column)

result = 0

for m in move:
  nr = row + m[0]
  nc = column + m[1]

  if nr < 1 or nr > 8 or nc < 1 or nc > 8:
    continue

  result += 1

print(result)

0개의 댓글

Powered by GraphCDN, the GraphQL CDN