게임 개발
p.119 N,M=map(int, input().split()) # N x M의 칸 A,B,direction=map(int, input().split()) # (A,B) 좌표, d 방향 d=[[0]*M for _ in range(N)] d[A][B]=1 table=[] for i in range(N): table.append(list(map(int, input().split()))) # 0 육지, 1 바다 dA=[-1, 0, 1, 0] dB=[0, 1, 0, -1] # 왼쪽으로 회전 def turn_left(): global direction direction -= 1 if direction==-1: direction=3 #시뮬레이션 시작 count=1 # 방문한 칸의 갯수 turn_time=0 whil..
2021. 1. 19.
왕실의 나이트
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.