๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
[๋ฐฑ์ค€][Node.js] 1408๋ฒˆ : 24 Algorithm - 24 - ๋ฌธ์ œ ๋„ํ˜„์ด๋Š” Counter Terror Unit (CTU)์—์„œ ์ผํ•˜๋Š” ํŠน์ˆ˜์š”์›์ด๋‹ค. ๋„ํ˜„์ด๋Š” ๋ชจ๋“  ์‚ฌ๊ฑด์„ ์ •ํ™•ํ•˜๊ฒŒ 24์‹œ๊ฐ„์ด ๋˜๋Š” ์ˆœ๊ฐ„ ํ•ด๊ฒฐํ•˜๋Š” ๊ฒƒ์œผ๋กœ ์œ ๋ช…ํ•˜๋‹ค. ๋„ํ˜„์ด๋Š” 1์‹œ๊ฐ„ ๋งŒ์— ๋ฒ”์ธ์„ ์žก์„ ์ˆ˜ ์žˆ์–ด๋„ ์žก์ง€ ์•Š๋Š”๋‹ค. ์ •ํ™•ํ•˜๊ฒŒ 24์‹œ๊ฐ„์ด ๋˜๋Š” ์ˆœ๊ฐ„์ด ์•„๋‹ˆ๋ฉด ์žก์ง€ ์•Š๋Š” CTU ํŠน์ˆ˜์š”์›์ด๋‹ค. 2008๋…„ 3์›” 3์ผ ์›”์š”์ผ, CTU๋Š” ์ƒˆํ•™๊ธฐ์— ๋งž์ถฐ ํ•ตํญํƒ„์„ ๋‚ ๋ฆฌ๊ฒ ๋‹ค๋Š” ํ…Œ๋Ÿฌ ์ •๋ณด๋ฅผ ์ž…์ˆ˜ํ–ˆ๋‹ค. CTU์—์„œ๋Š” ํŠน์ˆ˜์š”์› ๋„ํ˜„์ด์—๊ฒŒ ์ด ์ž„๋ฌด๋ฅผ ๋งก๊ฒผ๋‹ค. CTU์˜ ํ”„๋กœ๊ทธ๋ž˜๋จธ ์ค€๊ทœ๋Š” ์ด ์‚ฌ๊ฑด์˜ ๋ฐฐํ›„๊ฐ€ ๊น€์„ ์˜์ด๋ž€ ๊ฒƒ์„ ํ•ดํ‚น์„ ํ†ตํ•ด ๋ฐํ˜€๋‚ด์—ˆ๋‹ค. ๋„ํ˜„์ด๋Š” ์„ ์˜์ด๋ฅผ ์ž„๋ฌด๋ฅผ ์‹œ์ž‘ํ•œ์ง€ ์ •ํ™•ํ•˜๊ฒŒ 24์‹œ๊ฐ„์ด ๋˜๋Š” ์ˆœ๊ฐ„์— ์žก์œผ๋ ค๊ณ  ํ•œ๋‹ค. ๋งŒ์•ฝ ์ง€๊ธˆ ์‹œ๊ฐ„์ด 13:52:30์ด๊ณ , ์ž„๋ฌด๋ฅผ ์‹œ์ž‘ํ•œ ์‹œ๊ฐ„์ด 14:00.. 2021. 6. 25.
[๋ฐฑ์ค€][Node.js] 1373๋ฒˆ : 2์ง„์ˆ˜ 8์ง„์ˆ˜ Algorithm - 2์ง„์ˆ˜ 8์ง„์ˆ˜ - ๋ฌธ์ œ 2์ง„์ˆ˜๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, 8์ง„์ˆ˜๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ž…์ถœ๋ ฅ ์˜ˆ์‹œ ๋ฌธ์ œ ํ’€๊ธฐ const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); let input = ""; rl.on("line", function (line) { input = line.toString(); }).on("close", function () { let result = ""; let start = input.length - 3; let mid = input.length - 2; let end = input.lengt.. 2021. 6. 24.
[๋ฐฑ์ค€][Node.js] 1357๋ฒˆ : ๋’ค์ง‘ํžŒ ๋ง์…ˆ Algorithm - ๋’ค์ง‘ํžŒ ๋ง์…ˆ - ๋ฌธ์ œ ์–ด๋–ค ์ˆ˜ X๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, X์˜ ๋ชจ๋“  ์ž๋ฆฌ์ˆ˜๊ฐ€ ์—ญ์ˆœ์ด ๋œ ์ˆ˜๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ๋‹ค. Rev(X)๋ฅผ X์˜ ๋ชจ๋“  ์ž๋ฆฌ์ˆ˜๋ฅผ ์—ญ์ˆœ์œผ๋กœ ๋งŒ๋“œ๋Š” ํ•จ์ˆ˜๋ผ๊ณ  ํ•˜์ž. ์˜ˆ๋ฅผ ๋“ค์–ด, X=123์ผ ๋•Œ, Rev(X) = 321์ด๋‹ค. ๊ทธ๋ฆฌ๊ณ , X=100์ผ ๋•Œ, Rev(X) = 1์ด๋‹ค. ๋‘ ์–‘์˜ ์ •์ˆ˜ X์™€ Y๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, Rev(Rev(X) + Rev(Y))๋ฅผ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค ์ž…์ถœ๋ ฅ ์˜ˆ์‹œ ๋ฌธ์ œ ํ’€๊ธฐ let fs = require("fs"); let input = fs.readFileSync("/dev/stdin") .toString() .split(" ") .map((el) => Number(el.split("").reverse().join(""))).reduce((past,.. 2021. 6. 23.
[๋ฐฑ์ค€][Node.js] 1330๋ฒˆ : ๋‘ ์ˆ˜ ๋น„๊ตํ•˜๊ธฐ Algorithm - ๋‘ ์ˆ˜ ๋น„๊ตํ•˜๊ธฐ - ๋ฌธ์ œ ๋‘ ์ •์ˆ˜ A์™€ B๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, A์™€ B๋ฅผ ๋น„๊ตํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. • A๊ฐ€ B๋ณด๋‹ค ํฐ ๊ฒฝ์šฐ์—๋Š” '>'๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. • A๊ฐ€ B๋ณด๋‹ค ์ž‘์€ ๊ฒฝ์šฐ์—๋Š” ''); else console.log('=='); } solution(); 2021. 6. 22.
[๋ฐฑ์ค€][Node.js] 1292๋ฒˆ : ์‰ฝ๊ฒŒ ํ‘ธ๋Š” ๋ฌธ์ œ Algorithm - ์‰ฝ๊ฒŒ ํ‘ธ๋Š” ๋ฌธ์ œ - ๋ฌธ์ œ ๋™ํ˜ธ๋Š” ๋‚ด๋…„์— ์ดˆ๋“ฑํ•™๊ต๋ฅผ ์ž…ํ•™ํ•œ๋‹ค. ๊ทธ๋ž˜์„œ ๋™ํ˜ธ ์–ด๋จธ๋‹ˆ๋Š” ์ˆ˜ํ•™ ์„ ํ–‰ ํ•™์Šต์„ ์œ„ํ•ด ์‰ฝ๊ฒŒ ํ‘ธ๋Š” ๋ฌธ์ œ๋ฅผ ๋™ํ˜ธ์—๊ฒŒ ์ฃผ์—ˆ๋‹ค. ์ด ๋ฌธ์ œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค. 1์„ ํ•œ ๋ฒˆ, 2๋ฅผ ๋‘ ๋ฒˆ, 3์„ ์„ธ ๋ฒˆ, ์ด๋Ÿฐ ์‹์œผ๋กœ 1 2 2 3 3 3 4 4 4 4 5 ... ์ด๋Ÿฌํ•œ ์ˆ˜์—ด์„ ๋งŒ๋“ค๊ณ  ์–ด๋Š ์ผ์ •ํ•œ ๊ตฌ๊ฐ„์„ ์ฃผ๋ฉด ๊ทธ ๊ตฌ๊ฐ„์˜ ํ•ฉ์„ ๊ตฌํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ํ•˜์ง€๋งŒ ๋™ํ˜ธ๋Š” ํ˜„์žฌ ๋” ์–ด๋ ค์šด ๋ฌธ์ œ๋ฅผ ํ‘ธ๋Š๋ผ ๋ฐ”์˜๊ธฐ์— ์šฐ๋ฆฌ๊ฐ€ ๋™ํ˜ธ๋ฅผ ๋„์™€์ฃผ์ž. ์ž…์ถœ๋ ฅ ์˜ˆ์‹œ ๋ฌธ์ œ ํ’€๊ธฐ const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); let input.. 2021. 6. 21.
[๋ฐฑ์ค€][Node.js] 1252๋ฒˆ : ์ด์ง„์ˆ˜ ๋ง์…ˆ Algorithm - ์ด์ง„์ˆ˜ ๋ง์…ˆ - ๋ฌธ์ œ ๋‘ ๊ฐœ์˜ ์ด์ง„์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ ์ด๋ฅผ ๋”ํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ž…์ถœ๋ ฅ ์˜ˆ์‹œ ๋ฌธ์ œ ํ’€๊ธฐ const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); let input = []; rl.on("line", function (line) { input = line.toString().split(" ").map((el) => el.split("").reverse()); }).on("close", function () { let longNum, shortNum; if (input[0].length < input[.. 2021. 6. 20.