- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathknight.py
More file actions
Latest commit
20 lines (16 loc) Β· 663 Bytes
/
Copy pathknight.py
File metadata and controls
20 lines (16 loc) Β· 663 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
forstepinsteps :
# μ΄λνκ³ μ νλ μμΉ νμΈ
next_row=row+step[0]
next_column=column+step[1]
# ν΄λΉ μμΉλ‘ μ΄λμ΄ κ°λ₯νλ€λ©΄ μΉ΄μ΄νΈ μ¦κ°
ifnext_row>=1andnext_row<=8andnext_column>=1andnext_column<=8 :
result+=1
print(result)