전체 글 26

[프로그래머스 Lv1 - 2021 카카오 채용연계형 인턴십] 숫자 문자열과 영단어 (Python)

def solution(s): answer = [] s = list(s) while (len(s) > 0) : try : s[0] = int(s[0]) answer.append(s[0]) del s[0] except : if s[0] == 'z' : answer.append(0) del s[:4] elif s[0] == 'o' : answer.append(1) del s[:3] elif s[0] == 't' : if s[1] == 'w' : answer.append(2) del s[:3] else : answer.append(3) del s[:5] elif s[0] == 'f' : if s[1] == 'o' : answer.append(4) del s[:4] else : answer.append(5) d..

알고리즘 2022.06.30

[프로그래머스 Lv1 - 2019 KAKAO BLIND RECRUITMENT] 실패율 (Python)

def solution(N, stages): length = len(stages) answer = [] fail = dict() for i in range(1, N+1) : cnt = stages.count(i) val = cnt / length fail[i] = val length -= cnt fail = sorted(fail.items(), key=lambda x:x[1], reverse=True) for i in fail : answer.append(i[0]) return answer ㅎㅎ.. 웬일로 쉽게 끝나나 했다 ,, def solution(N, stages): length = len(stages) answer = [] fail = dict() for i in range(1, N+1) : cn..

알고리즘 2022.06.30

[프로그래머스 Lv1 - 2022 KAKAO BLIND RECRUITMENT] 신고 결과 받기 (Python)

def solution(id_list, report, k): li = dict() result = dict() send_li = [] receive_li = [] answer = [] all = [] for i in range(len(report)) : send, receive = report[i].split() if [send, receive] in all : continue else : send_li.append(send) receive_li.append(receive) all.append([send, receive]) li[receive] = 0 for i in id_list : result[i] = 0 for j in receive_li : li[j] += 1 for key, value in li..

알고리즘 2022.06.28

[프로그래머스 Lv2] 행렬의 곱셈 (Python)

* 행렬의 곱셈 참고 자료 * https://mathbang.net/562?category=432667 행렬의 곱셈, 행렬의 거듭제곱 행렬의 곱셈은 행렬의 실수배에 비하면 훨씬 어려워요. 행렬을 곱할 수 있는 조건이 있어 이 조건을 만족하지 않으면 곱셈을 하지 못하는 경우도 있어요. 게다가 계산방식도 매우 까다롭죠. 도 mathbang.net ↓ ↓ ↓ → [2, 3, 2] [5, 4, 3] → [4, 2, 4] [2, 4, 1] → [3, 1, 4] [3, 1, 1] arr1[0][0] * arr2[0][0] arr1[0][1] * arr2[1][0] 더한 게 answer[0][0] = 22 arr1[0][2] * arr2[2][0] arr1[0][0] * arr2[0][1] arr1[0][1] * a..

알고리즘 2022.06.26