반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 브루트포스
- DP
- 다이나믹 프로그래밍
- 다익스트라
- 백준
- level0
- N과M
- 파이썬
- python
- BFS
- 그리디
- 가상메모리
- level3
- 코딩테스트
- programmers
- 수학
- level1
- 재귀
- 에라스토테네스의 체
- MYSQL
- 딕셔너리
- 스택
- 힙
- BOJ
- 가상메모리 관리
- 구현
- 운영체제
- 프로그래머스
- level2
- dfs
Archives
- Today
- Total
동캄의 코딩도장
프로그래머스 level1 [성격 유형 검사 하기] 파이썬 본문
반응형
https://school.programmers.co.kr/learn/courses/30/lessons/118666
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
# 프로그래머스 level1 성격 유형 검사하기
from collections import defaultdict
def solution(survey, choices):
answer = ''
lst = defaultdict(int)
for i in range(len(choices)):
l = list(map(str, survey[i]))
if choices[i] == 4:
continue
elif choices[i] > 4:
lst[l[1]] += (choices[i]-4)
elif choices[i] < 4:
lst[l[0]] += (4-choices[i])
if lst['T'] > lst['R']:
answer += 'T'
else:
answer += 'R'
if lst['C'] >= lst['F']:
answer += 'C'
else:
answer += 'F'
if lst['J'] >= lst['M']:
answer += 'J'
else:
answer += 'M'
if lst['A'] >= lst['N']:
answer += 'A'
else:
answer += 'N'
print(lst)
return answer
# print(solution(["AN", "CF", "MJ", "RT", "NA"], [5, 3, 2, 7, 5]))
반응형
'코테 > 프로그래머스' 카테고리의 다른 글
프로그래머스 level1 [바탕화면 정리] 파이썬 (0) | 2023.03.12 |
---|---|
프로그래머스 level2 [두 큐 합 같게 만들기] 파이썬 (0) | 2022.09.03 |
프로그래머스 level3 [보석 쇼핑] 파이썬 (0) | 2022.04.21 |
프로그래머스 level3 [ [1차] 셔틀버스] 파이썬 (0) | 2022.04.19 |
프로그래머스 level3 [N으로 표현] 파이썬 (0) | 2022.04.13 |