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 dad95e1

Browse files
Add 모의고사
1 parent bdf8c30 commit dad95e1

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

‎level-1/모의고사.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,26 @@ function solution(answers) {
5858
}
5959

6060
return result;
61-
}
61+
}
62+
63+
//정답 3 - yongchanson
64+
function solution(answers) {
65+
let score = [];
66+
let answer = [];
67+
let a1 = [1, 2, 3, 4, 5];
68+
let a2 = [2, 1, 2, 3, 2, 4, 2, 5];
69+
let a3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5];
70+
71+
score.push(answers.filter((a, i) => a === a1[i % a1.length]).length);
72+
score.push(answers.filter((a, i) => a === a2[i % a2.length]).length);
73+
score.push(answers.filter((a, i) => a === a3[i % a3.length]).length);
74+
75+
for (let i = 0; i < score.length; i++) {
76+
const max = Math.max(...score);
77+
if (score[i] === max) {
78+
answer.push(i + 1);
79+
}
80+
}
81+
82+
return answer;
83+
}

0 commit comments

Comments
(0)

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