본문 바로가기
반응형

프로그래머스/1단계83

(Python/LV1) 키패드 누르기 문제출처: https://school.programmers.co.kr/learn/courses/30/lessons/67256 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: def solution(numbers, hand): answer ='' pad = {'1':(0,0), '2':(0,1), '3':(0,2), '4':(1,0), '5':(1,1), '6':(1,2), '7':(2,0), '8':(2,1), '9':(2,2), '*':(3,0), '0':(3,1), '#':(3,2) } left = pad['*'] #처음 왼손 right = pa.. 2022. 9. 15.
(Python/LV1) 완주하지 못한 선수 문제 출처: https://school.programmers.co.kr/learn/courses/30/lessons/42576 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: 첫 시도 def solution(participant, completion): return ''.join([i for i in participant if i not in completion]) 동명이인 땜에 실패 >> 딕셔너리 사용 from collections import Counter def solution(participant, completion): res = Count.. 2022. 9. 14.
(Python/LV1)체육복 문제출처: https://school.programmers.co.kr/learn/courses/30/lessons/42862 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: def solution(n, lost, reserve): reserve_p = set(reserve) - set(lost) # 여유있는사람 lost_p = set(lost) - set(reserve)# 잃어버린사람 for i in reserve_p: be = i - 1 af = i + 1 if be in lost_p:# 전 숫자가 있는경우 lost_p.remove(be)# 전 숫.. 2022. 9. 14.
(Python/LV1) 로또의 최고순위와 최저순위 문제 출처: https://school.programmers.co.kr/learn/courses/30/lessons/77484 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: def solution(lottos, win_nums): rank = {6 : 1, 5 : 2 , 4 : 3, 3 : 4, 2 : 5, 1 : 6, 0: 6} win = list(set(lottos)&set(win_nums)) if lottos.count(0) == 6: return [1 , (rank[len(win)])] else: return [rank[len(win)] -.. 2022. 9. 14.
(Python/LV1) 다트게임 문제출처: https://school.programmers.co.kr/learn/courses/30/lessons/17682 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: def solution(dartResult): point = ['10' if i =='A' else i for i in dartResult.replace('10', 'A')] # 다시 A 이면 10으로 해서 저장 dic = {"S" : 1, "D" : 2, "T" : 3} # dic 저장 stack = [] # stack 만듦 for i in point: if i.isnumeri.. 2022. 9. 14.
(Python/LV1)실패율 문제출처:https://school.programmers.co.kr/learn/courses/30/lessons/42889 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: def solution(N, stages): result = {} length = len(stages) for i in range(1, N + 1): if length != 0: count = stages.count(i) # 분자 result[i] = count / length length -= count # 분모 갯수 else: result[i] =0 return sorted(r.. 2022. 9. 13.
반응형