본문 바로가기
728x90
320x100

💻 하나씩 차곡차곡/프로그래머스 (Python)93

[프로그래머스/Lv.2/파이썬] H-Index 먼저 H-Index 를 이해하는 게 우선... 설명 들으니까 대에에에충 알겠다.... 포인트는 자신이 저널에 등재한 전체 논문중 많이 인용된 순으로 정렬한 후, 피인용수가 논문수와 같아지거나 피인용수가 논문수보다 작아지기 시작하는 숫자가 바로 나의 h가 됩니다.  설명 링크 : https://www.ibric.org/bric/trend/bio-series.do;jsessionid=E9A70E25FF98E2D67C77469C6908F3D7?mode=series_view&newsArticleNo=8802417&articleNo=8882714&beforeMode=latest_list#!/list Bio뉴스 > 동향 | BRIC" data-og-description="일반적으로 특정 연구원의 연구성과를 평가하기.. 2024. 10. 16.
[프로그래머스/Lv.1/Python] 모의고사 def solution(answers): answer = [] supoja1 = [1, 2, 3, 4, 5] supoja2 = [2, 1, 2, 3, 2, 4, 2, 5] supoja3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5] score = [0, 0, 0] for idx, value in enumerate(answers) : if value == supoja1[idx % len(supoja1)]: score[0] += 1 if value == supoja2[idx % len(supoja2)]: score[1] += 1 if value == supoja3[idx % len(supoja3)]: score[2] += 1 for idx, s in enumerate(score): if s ==.. 2024. 1. 26.
[프로그래머스/Lv.2/Python] 가장 큰 수 처음 풀이from itertools import permutationsdef solution(numbers): answer = '' arr = [] for i in permutations(numbers, len(numbers)): arr.append(''.join(map(str,i))) arr = sorted(map(int, arr), reverse=True) return str(arr[0])permutations 순열 함수를 사용하여 모든 경우의 수를 담고 가장 큰 수로 정렬한 후에 첫번째 인덱스의 값을 문자로 변환하여 리턴하는 방식으로 해주었는데, 테스트 케이스는 맞았지만 정확성에서 30점도 안되는 점수 획득.....ㅋ 다시 풀기def soluti.. 2024. 1. 25.
[프로그래머스/Lv.1/Pyhton] K번째수 def solution(array, commands): answer = [] for command in commands : list = array[command[0]-1:command[1]] list = sorted(list) answer.append(list[command[2]-1]) return answer 2024. 1. 24.
[프로그래머스/Lv2/Python] 큰 수 만들기 def solution(number, k): stack = [number[0]] for num in number[1:]: while len(stack) > 0 and stack[-1] 0: k -= 1 stack.pop() stack.append(num) if k != 0: stack = stack[:-k] return ''.join(stack) 문제 이해 자체가 너무 어려웠고 그래서 결국 자꾸 하나가 테스트 안넘어 가서....다른 분 풀이 가지고 옴. stack을 사용했고 마지막에 if k!= 0 부분 까지 처리해주지 않으면 예외처리가 안된다는 것을 명심. 2024. 1. 23.
[프로그래머스/Lv2/Python] 구명보트 def solution(people, limit): answer = 1 people.sort() weigth = 0 for i in people: if limit < weigth + i: answer += 1 weigth = i else : weigth += i return answer 일케 짰는데 테스트 통과하고 정확성 22퍼센트대로 ㅋㅋㅋㅋㅋㅋㅋ거의 틀린거나 다름 없이 됨. 다른 분 풀이를 가지고 왔다........ def solution(people, limit): people.sort() start, end = 0, len(people)-1 count = 0 while start 2024. 1. 22.
728x90
320x100