공부/📝 프로그래머스(126)
-
숫자 짝꿍 - Python
1. 풀이 코드 def solution(X, Y): X_list = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] Y_list = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] for i in range(0, 10): X_list[i] = X.count(str(i)) Y_list[i] = Y.count(str(i)) answer = '' for i in range(9, -1, -1): if i != 0 or len(answer) != 0: while X_list[i] != 0 and Y_list[i] != 0: answer += f"{i}" X_list[i] -= 1 Y_list[i] -= 1 elif i == 0 and (X_list[i] != 0 and Y_list[i] != 0):..
2024.01.25 -
로또의 최고 순위와 최저 순위 - Python
1. 풀이 코드 def solution(lottos, win_nums): answer = [] temp_set = set(lottos) win_count = 0 lose_count = 0 for item in temp_set: if item != 0: if item in win_nums: win_count += 1 else: lose_count += 1 answer = [min(1 + lose_count, 6), min(7 - win_count, 6)] return answer set() 집합으로 중복을 제거한 다음 풀었습니다. 2. 다른 사람 풀이 코드 def solution(lottos, win_nums): rank=[6,6,5,4,3,2,1] cnt_0 = lottos.count(0) ans = 0..
2024.01.24 -
[1차] 다트 게임 - Python
1. 풀이 코드 def solution(dartResult): answer = 0 temp = '' score_list = [] i = 0 for item in dartResult: if item.isdigit(): temp += item else: if item == 'S': score_list.append(int(temp) ** 1) i += 1 elif item == 'D': score_list.append(int(temp) ** 2) i += 1 elif item == 'T': score_list.append(int(temp) ** 3) i += 1 elif item == '*': score_list[i - 1] = score_list[i - 1] * 2 if i - 2 >= 0: score_li..
2023.12.13 -
실패율 - Python
1. 풀이 코드 def solution(N, stages): answer = [] count_list1 = [] count_list2 = [] people = len(stages) for i in range(1, N + 1): if people == 0: count_list1.append(0) count_list2.append(0) else: count_list1.append((stages.count(i)/people)) count_list2.append((stages.count(i)/people)) people -= stages.count(i) count_list2.sort() # print(count_list1) # print(count_list2) for _ in range(N): search_ta..
2023.12.13 -
덧칠하기 - Python
1. 풀이 코드 def solution(n, m, section): answer = 0 wall_list = [] for _ in range(n + 1): wall_list.append(True) for item in section: wall_list[item] = False print(wall_list) for i in range(1, n + 1): print(i, "before", wall_list) if wall_list[i] == False: for j in range(i, min(i + m, n + 1)): wall_list[j] = True answer += 1 print("check") print(i, "after", wall_list) return answer print(solution(8..
2023.12.11 -
기사단원의 무기 - Python
1. 풀이 코드 def solution(number, limit, power): answer = 0 num_list = [0] * (number + 1) for i in range(1, number + 1): for j in range(i, number + 1, i): num_list[j] += 1 for item in num_list: if item
2023.12.10 -
[PCCE 기출문제] 1번 / 출력 - Python
1. 풀이 코드 string_msg = 'Spring is beginning' int_val = 3 string_val = '3' print(string_msg) print(int_val + 10) print(string_val + "10") 프로그래머스: https://school.programmers.co.kr/learn/courses/30/lessons/250133 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr
2023.12.10