diff --git a/README.md b/README.md index eb877fe..ed622fb 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ ### Level 1 ✅ -- 전체 문제 수: 55문제 -- 풀이 문제 수: 55문제 +- 전체 문제 수: 56문제 +- 풀이 문제 수: 56문제 | 번호 | 문제 출처 | 풀이 | | --- | ------- | --- | @@ -77,6 +77,7 @@ | 53 | [하샤드 수](https://school.programmers.co.kr//learn/courses/30/lessons/12947) | [하샤드-수.js](https://github.com/codeisneverodd/programmers-coding-test/blob/main/level-1/하샤드-수.js) | | 54 | [핸드폰 번호 가리기](https://school.programmers.co.kr//learn/courses/30/lessons/12948) | [핸드폰-번호-가리기.js](https://github.com/codeisneverodd/programmers-coding-test/blob/main/level-1/핸드폰-번호-가리기.js) | | 55 | [행렬의 덧셈](https://school.programmers.co.kr//learn/courses/30/lessons/12950) | [행렬의-덧셈.js](https://github.com/codeisneverodd/programmers-coding-test/blob/main/level-1/행렬의-덧셈.js) | +| 56 | [성격 유형 검사하기](https://school.programmers.co.kr/learn/courses/30/lessons/118666) | [성격-유형-검사하기.js](https://github.com/codeisneverodd/programmers-coding-test/blob/main/level-1/성격-유형-검사하기.js) | ### Level 2 👨🏻‍💻(풀이 중..) diff --git "a/level-1/\354\204\261\352\262\251-\354\234\240\355\230\225-\352\262\200\354\202\254\355\225\230\352\270\260.js" "b/level-1/\354\204\261\352\262\251-\354\234\240\355\230\225-\352\262\200\354\202\254\355\225\230\352\270\260.js" new file mode 100644 index 0000000..cad6a1e --- /dev/null +++ "b/level-1/\354\204\261\352\262\251-\354\234\240\355\230\225-\352\262\200\354\202\254\355\225\230\352\270\260.js" @@ -0,0 +1,45 @@ +//https://github.com/codeisneverodd/programmers-coding-test +//더 좋은 풀이가 존재할 수 있습니다. + +//정답 1 - ssi02014 +function solution(survey, choices) { + const points = [3, 2, 1, 0, 1, 2, 3]; + const pointBoard = { + R: 0, + T: 0, + C: 0, + F: 0, + J: 0, + M: 0, + A: 0, + N: 0, + }; + let result = ""; + + // 카테고리 별 점수 추가 + for (let i = 0; i < survey.length; i++) { + const categories = survey[i]; + + if (choices[i] < 4) { + pointBoard[categories[0]] += points[choices[i] - 1]; + } else if (choices[i] > 4) { + pointBoard[categories[1]] += points[choices[i] - 1]; + } + } + + const pointBoardEntries = Object.entries(pointBoard); + + // 지표에 맞게 결과 값 도출 + for (let i = 0; i < pointBoardEntries.length; i += 2) { + const [curCategory, curValue] = pointBoardEntries[i]; + const [nextCategory, nextValue] = pointBoardEntries[i + 1]; + + if (curValue < nextValue) { + result += nextCategory; + } else { + result += curCategory; + } + } + + return result; +} \ No newline at end of file