forked from ndb796/python-for-coding-test
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path3.py
More file actions
19 lines (16 loc) Β· 676 Bytes
/
3.py
File metadata and controls
19 lines (16 loc) Β· 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# νμ¬ λμ΄νΈμ μμΉ μ
λ ₯λ°κΈ°
input_data = input()
row = int(input_data[1])
column = int(ord(input_data[0])) - int(ord('a')) + 1
# λμ΄νΈκ° μ΄λν μ μλ 8κ°μ§ λ°©ν₯ μ μ
steps = [(-2, -1), (-1, -2), (1, -2), (2, -1), (2, 1), (1, 2), (-1, 2), (-2, 1)]
# 8κ°μ§ λ°©ν₯μ λνμ¬ κ° μμΉλ‘ μ΄λμ΄ κ°λ₯νμ§ νμΈ
result = 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:
result += 1
print(result)