Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 390a26b

Browse files
committed
feat: 성격 유형 검사 풀이 - 2022 KAKAO TECH INTERNSHIP
1 parent fa4fafe commit 390a26b

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

‎level-1/성격-유형-검사.js‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//더 좋은 풀이가 존재할 수 있습니다.
3+
4+
//정답 1 - ssi02014
5+
function solution(survey, choices) {
6+
const points = [3, 2, 1, 0, 1, 2, 3];
7+
const pointBoard = {
8+
R: 0,
9+
T: 0,
10+
C: 0,
11+
F: 0,
12+
J: 0,
13+
M: 0,
14+
A: 0,
15+
N: 0,
16+
};
17+
let result = "";
18+
19+
// 카테고리 별 점수 추가
20+
for (let i = 0; i < survey.length; i++) {
21+
const categories = survey[i];
22+
23+
if (choices[i] < 4) {
24+
pointBoard[categories[0]] += points[choices[i] - 1];
25+
} else if (choices[i] > 4) {
26+
pointBoard[categories[1]] += points[choices[i] - 1];
27+
}
28+
}
29+
30+
const pointBoardEntries = Object.entries(pointBoard);
31+
32+
// 지표에 맞게 결과 값 도출
33+
for (let i = 0; i < pointBoardEntries.length; i += 2) {
34+
const [curCategory, curValue] = pointBoardEntries[i];
35+
const [nextCategory, nextValue] = pointBoardEntries[i + 1];
36+
37+
if (curValue < nextValue) {
38+
result += nextCategory;
39+
} else {
40+
result += curCategory;
41+
}
42+
}
43+
44+
return result;
45+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /