-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpg_118666
More file actions
48 lines (40 loc) · 1.16 KB
/
pg_118666
File metadata and controls
48 lines (40 loc) · 1.16 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# https://school.programmers.co.kr/learn/courses/30/lessons/118666
# 성격 유형 검사하기
def solution(survey, choices):
resultDic = {
"R": 0,
"T": 0,
"C": 0,
"F": 0,
"J": 0,
"M": 0,
"A": 0,
"N": 0
}
result = ""
for i in range(len(choices)):
if choices[i] == 4:
continue
# "AN"이면 "A", "N" 나눠서 생각
a = survey[i][0]
b = survey[i][1]
# 4보다 작은 값이면 a에 값 +
if choices[i] < 4:
number = 4-choices[i]
resultDic[a] += number
# 4를 넘는 값이면 b가 +
elif choices[i] > 4:
number = choices[i]-4
resultDic[b] += number
def returnResult(a, b):
result = ""
if resultDic[a] == resultDic[b]:
result += min(a, b)
else:
result += a if resultDic[a] > resultDic[b] else b
return result
result += returnResult("R", "T")
result += returnResult("C", "F")
result += returnResult("J", "M")
result += returnResult("A", "N")
return result