[Programmers] 완전탐색 level1 모의고사
각 수포자가 찍는 패턴 👉전체👈를 변수에 저장
function solution(answers) {
const result = [];
const supoPointArray = [0, 0, 0];
const supo1Pattern = [1, 2, 3, 4, 5];
const supo2Pattern = [2, 1, 2, 3, 2, 4, 2, 5];
const supo3Pattern = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5];
answers.forEach((answer, answerIdx) => {
if (answer === supo1Pattern[answerIdx % 5]) {
supoPointArray[0] += 1;
}
if (answer === supo2Pattern[answerIdx % 8]) {
supoPointArray[1] += 1;
}
if (answer === supo3Pattern[answerIdx % 10]) {
supoPointArray[2] += 1;
}
});
const maxPoint = Math.max(...supoPointArray);
supoPointArray.forEach((point, index) => {
if (maxPoint === point) {
result.push(index + 1);
}
});
return result.sort((x, y) => x - y);
}
각 수포자 케이스를 다르게 생각했고, 각각의 경우를 따로따로 처리하다보니 오류가 생성된듯 하다
(원인 파악 후 처리 예정)