[프로그래머스/Programmers] 피로도 피로도 📝문제 👨💻코드 from itertools import permutations def solution(k, dungeons): answer = -1 items = list(permutations(dungeons, len(dungeons))) for i in range(len(items)): cnt = 0 temp = k for j in range(len(items[i])): if items[i][j][0] Algorithm/Problem Solving
[프로그래머스/Programmers] 2주차_상호평가 2주차_상호평가 📝문제 👨💻코드 def solution(scores): answer = '' board = [] scores2 = [] for i in range(len(scores)): scores2.append([]) for i in range(len(scores[0])): for j in range(len(scores)): scores2[i].append(scores[j][i]) for i in range(len(scores2)): if scores2[i][i] == min(scores2[i]) and scores2[i].count(scores2[i][i]) == 1: scores2[i].remove(scores2[i][i]) board.append(sum(scores2[i]) / len(scor.. Algorithm/Problem Solving
[프로그래머스/Programmers] 4주차_직업군 추천하기 4주차_직업군 추천하기 📝문제 👨💻코드 from collections import defaultdict def solution(table, languages, preference): answer = '' dic = defaultdict(int) for i in table: a = i.split() target = a[0] for j in range(1, len(a)): if a[j] in languages: b = preference[languages.index(a[j])] dic[target] += (b * (6 - a.index(a[j]))) answer = max(dic, key = dic.get) result = list(zip(dic.keys(), dic.values())) result = s.. Algorithm/Problem Solving
[프로그래머스/Programmers] 8주차_최소직사각형 8주차_최소직사각형 📝문제 👨💻코드 def solution(sizes): maxArr = [] minArr = [] for i in sizes: maxArr.append(max(i)) minArr.append(min(i)) return max(maxArr) * max(minArr) 🤔Review 그냥 간단한 수학문제이다. i에서 최소값과 최대값을 따로 저장 한 뒤 최대값 배열에서 최대값을 가져오고 최소값 배열에서 최대값을 가져온 뒤 곱한 값을 return 해줬다. Algorithm/Problem Solving
[프로그래머스/Programmers] [1차] 다트 게임 [1차] 다트 게임 📝문제 👨💻코드 def solution(dartResult): answer = 0 temp = '' temp2 = [] for i in range(len(dartResult)): if dartResult[i].isdigit(): temp += dartResult[i] if dartResult[i] == 'S': temp = int(temp) ** 1 temp2.append(temp) temp = '' if dartResult[i] == 'D': temp = int(temp) ** 2 temp2.append(temp) temp = '' if dartResult[i] == 'T': temp = int(temp) ** 3 temp2.append(temp) temp = '' if dartR.. Algorithm/Problem Solving
[프로그래머스/Programmers] 이상한 문자 만들기 이상한 문자 만들기 📝문제 👨💻코드 def solution(s): answer = '' temp = s.split(' ') for i in range(len(temp)): for j in range(len(temp[i])): if j % 2 == 0: answer += temp[i][j].upper() else: answer += temp[i][j].lower() answer += ' ' return answer[:-1] 🤔Review 간단한 문자열 문제이다. 처음에 문제를 잘못 읽어서 틀렸다ㅠㅠ 문제를 제발 꼼꼼히 읽어야겠다.... Algorithm/Problem Solving
[프로그래머스/Programmers] 영어 끝말잇기 영어 끝말잇기 📝문제 👨💻코드 def solution(n, words): answer = [] stack = [words[0]] cnt = 2 cnt2 = 1 for i in range(1, len(words)): if words[i][0] == stack[-1][-1] and words[i] not in stack: stack.append(words[i]) cnt += 1 if cnt > n: cnt = 1 cnt2 += 1 else: answer.append(cnt) answer.append(cnt2) break if len(stack) == len(words): answer.append(0) answer.append(0) return answer 🤔Review stack을 이용해서 간단하게 풀 수.. Algorithm/Problem Solving
[프로그래머스/Programmers] [3차] n진수 게임 [3차] n진수 게임 📝문제 👨💻코드 def change(n, base): T = "0123456789ABCDEF" q, r = divmod(n, base) if q == 0: return T[r] else: return change(q, base) + T[r] def solution(n, t, m, p): answer = '' a = -1 modeBit = 0 cnt = 1 stack = [] while modeBit == 0: a += 1 temp = list(change(a, n)) for i in range(len(temp)): if cnt == p: answer += temp[i] if len(answer) == t: modeBit = 1 break cnt += 1 else: stack.app.. Algorithm/Problem Solving
[프로그래머스/Programmers] 튜플 튜플 📝문제 👨💻코드 def solution(s): answer = [] result = [] arr = s[2:-2] arr = arr.split('},{') arr = sorted(arr, key=len) for i in arr: a = i.split(',') for j in a: if j not in answer: answer.append(j) for i in answer: result.append(int(i)) return result 🤔Review 간단한 문자열 문제다 },{ 로 split해주는게 문제의 핵심인것같다. Algorithm/Problem Solving
[프로그래머스/Programmers] [3차] 방금그곡 [3차] 방금그곡 📝문제 👨💻코드 import math def change(temp2): if 'A#' in temp2: temp2 = temp2.replace('A#', 'a') if 'C#' in temp2: temp2 = temp2.replace('C#', 'c') if 'D#' in temp2: temp2 = temp2.replace('D#', 'd') if 'F#' in temp2: temp2 = temp2.replace('F#', 'f') if 'G#' in temp2: temp2 = temp2.replace('G#', 'g') return temp2 def solution(m, musicinfos): answer = '' result = [] for i in range(len(musicin.. Algorithm/Problem Solving