๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๊ฐœ์ธ๊ณต๋ถ€/Algorithm

[๋ฐฑ์ค€][Node.js] 3052๋ฒˆ : ๋‚˜๋จธ์ง€

by ๐Ÿ‡๋ฐ•๋ด‰๋ด‰๐Ÿ‡ 2021. 10. 20.

 

 

Algorithm

-  ๋‚˜๋จธ์ง€ -

 


 

๋ฌธ์ œ

๋‘ ์ž์—ฐ์ˆ˜ A์™€ B๊ฐ€ ์žˆ์„ ๋•Œ, A%B๋Š” A๋ฅผ B๋กœ ๋‚˜๋ˆˆ ๋‚˜๋จธ์ง€ ์ด๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, 7, 14, 27, 38์„ 3์œผ๋กœ ๋‚˜๋ˆˆ ๋‚˜๋จธ์ง€๋Š” 1, 2, 0, 2์ด๋‹ค.

 

์ˆ˜ 10๊ฐœ๋ฅผ ์ž…๋ ฅ๋ฐ›์€ ๋’ค, ์ด๋ฅผ 42๋กœ ๋‚˜๋ˆˆ ๋‚˜๋จธ์ง€๋ฅผ ๊ตฌํ•œ๋‹ค. ๊ทธ ๋‹ค์Œ ์„œ๋กœ ๋‹ค๋ฅธ ๊ฐ’์ด ๋ช‡ ๊ฐœ ์žˆ๋Š”์ง€ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

 

์ž…์ถœ๋ ฅ ์˜ˆ์‹œ

 

๋ฌธ์ œ ํ’€๊ธฐ

let fs = require("fs");
let input = fs.readFileSync("/dev/stdin")
	.toString()
	.trim()
	.split("\n")
	.map((el) => Number(el))
	.map((el2) => el2 % 42);
let filterNumber = input.filter((el, idx) => input.indexOf(el) === idx);

console.log(filterNumber.length);

 

 

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€