왕실의 나이트
p.115 first_p=input() steps=[(2,-1),(2,1),(-2,-1),(-2,1),(1,-2),(-1,-2),(1,2),(-1,2)] count=0 # 맨 처음이 a,1 column=int(ord(first_p[0])-ord('a'))+1 row=int(first_p[1]) next_column=0 next_row=0 for step in steps: next_column=column+step[0] next_row=row+step[1] if next_column>=1 and next_column=1 and next_row
2021. 1. 19.
상하좌우
p. 110 s=int(input()) plans=input().split() dire=['R','L','U','D'] dx=[0,0,-1,1] dy=[1,-1,0,0] nx=1 ny=1 x=1 y=1 for plan in plans: for i in range(len(dire)): if dire[i]==plan: nx=x+dx[i] ny=y+dy[i] if nxs: continue else: x=nx y=ny print(x,y)
2021. 1. 18.