본문 바로가기

코딩 테스트124

게임 개발 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.113 hour=int(input()) count=0 for h in range(hour+1): for m in range(60): for s in range(60): if '3' in str(h)+str(m)+str(s): count+=1 print(count) 2021. 1. 18.
상하좌우 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.
무지네 먹방 라이브 p.316 import heapq def solution(food_times, k): table=[] if sum(food_times) 2021. 1. 17.
볼링공 고르기 p.315 방법 1 N,M=map(int, input().split()) weight=list(map(int, input().split())) count=0 for i in range(N): for j in range(i,N): if weight[i]!=weight[j]: count+=1 print(count) 방법 2 N,M=map(int, input().split()) weight=list(map(int, input().split())) count=0 array=[0]*(M+1) for i in range(N): array[weight[i]]+=1 for j in range(1, M+1): N -= array[j] count += array[j]*N print(count) 2021. 1. 16.