https://www.acmicpc.net/problem/3052
let input = require('fs').readFileSync('/dev/stdin').toString().trim().split('\n');
const mySet = new Set();
Set
Set 객체는 자료형에 관계 없이 원시 값과 객체 참조 모두 유일한 값을 저장할 수 있다. 즉, 어떤 값은 그 Set 콜렉션 내에서 유일합니다.
위와 같이 유일한 값을 저장하는 Set을 이용해서 문제를 풀었다.
로직은 분명 맞는데 채점에서 계속 틀렸다고 나와서 찾아보니 입력값을 가져올 때 공백이 있다고 해서 trim()으로 입력값에서 공백을 제거하니 바로 통과했다...
(아래 출처 trim 참고)
let input = require('fs').readFileSync('/dev/stdin').toString().trim().split('\n');
const numArr = input.map((x) => Number(x) % 42);
console.log([...new Set(numArr)].length);
set정의 : https://velog.io/@vvee1253/JavaScript-Set
trim : https://dpsc615.tistory.com/9