전체 글

지옥에서 올라온 강인한 프로그래머
from collections import deque def solution(prices): prices_queue = deque(prices) seconds = [] while prices_queue: second = 0 #queue에 있는 price 검사 for price in prices_queue: if price < prices_queue[0]: #헤드보다 가격 작으면 가격 떨어진 거 seconds.append(second) prices_queue.popleft() break #시간 흐름 second += 1 else: #for문 다 돌았으면 실행하는 코드 (가격이 계속 안 떨어진 경우) seconds.append(second - 1) prices_queue.popleft() return sec..
def solution(answers): length = len(answers) first_person_answer = [1,2,3,4,5] * 5001 second_person_answer = [2,1,2,3,2,4,2,5] * 1251 third_person_answer = [3,3,1,1,2,2,4,4,5,5] * 1001 scores = [0, 0, 0] for i in range(0, length): scores[0] += 1 if first_person_answer[i] == answers[i] else 0 scores[1] += 1 if second_person_answer[i] == answers[i] else 0 scores[2] += 1 if third_person_answer[i] =..
import math def solution(n): # n => 총 칸 수, 사람은 1칸, 2칸 이렇게 뛸 수 있다. # a + 2*b = n # (a, b) 를 구하고 이에 대한 순열 문제를 풀어야 하는 건가? one_steps = [] #한 칸 갯수 two_steps = [] #두 칸 갯수 for i in range(0, n+1): one_step = i two_step = (n-i)//2 if (n-i)%2==0 else -1 #n에서 one_step 갯수를 빼면 two_step*2가 나오기 때문. 하지만 만약 이게 홀수라면 분할 실패 #그렇기 때문에 if문으로 처리하여 continue로 다음 one_step갯수를 세도록 한다. if two_step == -1: continue else: one_s..
박준영_
차가운 0과 1의 임페르노