Coding test/Programmers[python]
-
Programmers[Lv.1] - 둘만의 암호Coding test/Programmers[python] 2024. 2. 8. 15:35
https://school.programmers.co.kr/learn/courses/30/lessons/155652 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(s, skip, index): answer = '' array = [] for i in range(ord('a'), ord('z')+1): if chr(i) not in skip: array.append(chr(i)) print(array) for ch in s: next_idx = array.index(ch) + index answer += array[next_idx %..
-
Programmers[Lv.1] - 완주하지 못한 선수Coding test/Programmers[python] 2024. 2. 8. 15:10
https://school.programmers.co.kr/learn/courses/30/lessons/42576 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr from collections import Counter def solution(participant, completion): answer = '' cnt_participant = Counter(participant) cnt_completion = Counter(completion) answer = list(cnt_participant - cnt_completion)[0] return answer
-
Programmers[Lv.1] - 대충 만든 자판Coding test/Programmers[python] 2024. 2. 8. 12:57
https://school.programmers.co.kr/learn/courses/30/lessons/160586 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(keymap, targets): answer = [] for word in targets: count = [int(1e9)] * len(word) for x in range(len(word)): check=False for i in range(len(keymap)): for j in range(len(keymap[i])): if word[x] == keymap[i][j]:..
-
Programmers[Lv.1] - 체육복Coding test/Programmers[python] 2024. 2. 8. 12:43
https://school.programmers.co.kr/learn/courses/30/lessons/42862 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(n, lost, reserve): answer = n #여별옷을 가진 학생이 도난당한 학생 중 있는지 검사 new_lost = sorted([l for l in lost if l not in reserve]) new_reserve = sorted([r for r in reserve if r not in lost]) print(new_lost, new_reserve) for ..
-
Programmers[Lv.1] - 숫자 짝꿍Coding test/Programmers[python] 2024. 2. 8. 12:21
https://school.programmers.co.kr/learn/courses/30/lessons/131128 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 테케 11~15번 실패 (시간초과) def solution(X, Y): answer = '' array = [] x = list(X) y = list(Y) for num in x: if num in y: array.append(num) y.remove(num) if len(array) == 0: answer = "-1" elif all(n=="0" for n in array): answer = ..
-
Programmers[Lv.1] - 문자열 나누기Coding test/Programmers[python] 2024. 2. 8. 12:03
https://school.programmers.co.kr/learn/courses/30/lessons/140108 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 이해하는데만 시간이 많이 소요된 문제.. 개인적인 생각으로 중의적 표현이 들어간 문장이 많아 여러가지 해석이 나올 수 있는 문제같다. 입출력 예제를 보고 문제와 비교해가면서 한참이나 고민했다. ex) "aaabbaccccabba" 내가 이해한 바로는 1. 첫 글자를 읽는다. 이 글자를 x라고 칭한다. (첫번재로 "a") 2. 문자열은 왼쪽 (x 포함) 에서 오른쪽으로 (문자열 전체) 읽어나..
-
Programmers[Lv.1] - 로또의 최고 순위와 최저 순위Coding test/Programmers[python] 2024. 2. 8. 11:47
https://school.programmers.co.kr/learn/courses/30/lessons/77484 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(lottos, win_nums): answer = [] zero_count = lottos.count(0) correct_count = 0 rank = [-1, 6, 5, 4, 3, 2] for num in lottos: if num in win_nums: correct_count += 1 max_score = correct_count + zero_count min_scor..
-
Programmers[Lv.1] - [1차] 다트 게임Coding test/Programmers[python] 2024. 2. 8. 11:30
https://school.programmers.co.kr/learn/courses/30/lessons/17682 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(dartResult): answer = 0 score = 0 scores = [] skip = False for i, x in enumerate(dartResult): if skip: skip = False continue if x >= '0' and x = 2: scores[-2] = scores[-2] * 2 elif x == '#': scores[-1] = scores..