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 acf395e

Browse files
Merge pull request #86 from ssi02014/ssi02014
�성격 유형 검사 문제 풀이 및 README 수정
2 parents fa4fafe + 19f94de commit acf395e

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

‎README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
### Level 1 ✅
1919

20-
- 전체 문제 수: 55문제
21-
- 풀이 문제 수: 55문제
20+
- 전체 문제 수: 56문제
21+
- 풀이 문제 수: 56문제
2222

2323
| 번호 | 문제 출처 | 풀이 |
2424
| --- | ------- | --- |
@@ -77,6 +77,7 @@
7777
| 53 | [하샤드 수](https://school.programmers.co.kr//learn/courses/30/lessons/12947) | [하샤드-수.js](https://github.com/codeisneverodd/programmers-coding-test/blob/main/level-1/하샤드-수.js) |
7878
| 54 | [핸드폰 번호 가리기](https://school.programmers.co.kr//learn/courses/30/lessons/12948) | [핸드폰-번호-가리기.js](https://github.com/codeisneverodd/programmers-coding-test/blob/main/level-1/핸드폰-번호-가리기.js) |
7979
| 55 | [행렬의 덧셈](https://school.programmers.co.kr//learn/courses/30/lessons/12950) | [행렬의-덧셈.js](https://github.com/codeisneverodd/programmers-coding-test/blob/main/level-1/행렬의-덧셈.js) |
80+
| 56 | [성격 유형 검사하기](https://school.programmers.co.kr/learn/courses/30/lessons/118666) | [성격-유형-검사하기.js](https://github.com/codeisneverodd/programmers-coding-test/blob/main/level-1/성격-유형-검사하기.js) |
8081

8182
### Level 2 👨🏻‍💻(풀이 중..)
8283

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 によって変換されたページ (->オリジナル) /