[프로그래머스] 모의고사 Python
·
개발💻/알고리즘
아직 레벨1 문제들을 풀면서 감각을 살리는 중이다 def solution(answers): answer = [] rate = [-1] + [0]*3 omr_1 = [1,2,3,4,5]*((len(answers) //5) +1) omr_2 = [2,1,2,3,2,4,2,5]*((len(answers) //8) +1) omr_3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]*((len(answers) // 10) +1) for i in range(len(answers)): if answers[i] == omr_1[i]: rate[1] +=1 if answers[i] == omr_2[i]: rate[2] +=1 if answers[i] == omr_3[i]: rate[3] +=1 max_value..
[프로그래머스] 체육복 Python
·
개발💻/알고리즘
잘 푼거같은데 자꾸 테스트 통과를 못해서 엄청 찾다가 인덱스가 문제라는걸 알았다 항상 range 든 list 든 탐색할때 0 부터 시작한다는걸 잊지말자!! def solution(n, lost, reserve): cloth = [1]*(n+1) for i in range(1,n+1): if i in lost and i in reserve: cloth[i] = 1 continue if i in lost: cloth[i] = 0 if i in reserve: cloth[i] = 2 print(cloth) answer = 0 for i in range(1, n+1): if cloth[i] == 0: if i > 1: if cloth[i - 1] == 2: cloth[i] +=1 cloth[i - 1] -=1 ..
[프로그래머스] 실패율 Python
·
개발💻/알고리즘
진짜 처음부터 하나하나 하려다보니 넘 어렵다.. 기초부터 다 찾아봐야하고 ㅠㅠ def solution(N, stages): rate = [0]*(N+1) man = len(stages) stage = 1 while stage 0: count = 0 for st in stages: if st == stage: count +=1 rate[stage-1] = count / man man -= count stage += 1 rate = rate[:-1] answer = [] while len(rate) != len(answer): max_value = max(rate) print(max_value) for i in range(len(rate)): if rate[i] == max_va..
[프로그래머스] 성격 유형 검사하기 Python
·
개발💻/알고리즘
감을 살리기 위해 기본문제부터 시작하겠다 반복문 조건문도 까먹어서 검색하면서 풀었다.. def solution(survey, choices): answer = '' result_table = {'R' : 0, 'T': 0, 'C':0,'F':0,'J':0,'M':0,'A':0,'N':0 } Length = len(survey) index = 0 while index 4: result_table[survey[index][1]] += choices[index] - 4 elif choices[index] < 4: result_table[survey[index][0]] += 4 - choices[index] else: pass index +=1 if resu..
알고리즘 다시 시작...
·
개발💻/알고리즘
오늘부터 알고리즘 문제들을 다시 풀어보려 한다.. 여러모로 필요성을 느꼈기 때문이다 자바스크립트로 할가 파이썬으로 할가 하다가 그래도 싸피 시절부터 알고리즘은 파이썬으로 풀어왔기때문에 파이썬이 알고리즘 풀기에는 더 익숙해서 파이썬으로 문제들을 풀어보려한다 알고리즘을 놓은지 언 8개월정도 된거같은데 다시 걸음마 부터 시작해보겠다!!