[JS] 백준 3052번 나머지

jsg_ko·2021년 11월 16일
0

코테연습

목록 보기
11/21
const { count, info } = require("console");
const fs = require("fs"); //파일받기위해 필요
const { resourceLimits } = require("worker_threads");
const localFile = fs.existsSync("./input.txt"); // 내가 알고리즘 풀려는 폴더에 './input.txt'의 유무를 참,거짓으로 변수에 넣어라
const filePath = () => {
  // 참이면 내 input파일을 열고 그외는 백준의 알고리즘에서 주는 입력값을 받겠다.
  if (localFile) {
    return "./input.txt";
  }
  return "/dev/stdin";
};


const input = fs.readFileSync(filePath()).toString().trim().split("\n").map((el) => {return el.split(' ')}).map(el => Number(el))

const remainder = input.map((el) => {return el % 42})

const checkedNum = [];
remainder.forEach((el) => {
  if( checkedNum.indexOf(el) === -1){
    checkedNum.push(el);
  }
})

console.log(checkedNum.length);
profile
디버깅에서 재미를 추구하면 안되는 걸까

0개의 댓글