수학 테스트 점수를 기준으로 멘토와 멘티를 짝지으려 합니다.
멘토는 모든 수학테스트에서 멘티보다 성적이 높아야합니다.
각 배열을 통해 각 수학 시험의 결과가 성적순으로 학생번호가 입력됩니다.
멘토와 멘티가 이루어질 수 있는 모든 경우의 수를 출력하세요.
예시)
입력
3412
4321
3142
출력
3
({3,1}, {3,2}, {4,2} 세가지 경우가 가능)
<script>
function solution(test){
let answer = [];
let stand = test[0];
let found = false;
for(let i=0; i<stand.length-1;i++){
for(let j=i+1; j<stand.length; j++){
for(let k=1; k<test.length;k++){
if(test[k].indexOf(stand[i])>test[k].indexOf(stand[j])){
found = true;
}
}
if(found === false){
answer.push([stand[i],stand[j]]);
}
found = false;
}
}
return answer;
}
let arr=[[3, 4, 1, 2], [4, 3, 2, 1], [3, 1, 4, 2]];
console.log(solution(arr));
</script>