๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

ํ”„์—” ๊ณต๋ถ€

(151)
[๋ฐฑ์ค€/Node.js] 2444๋ฒˆ ๋ณ„์ฐ๊ธฐ || ํ’€์ด JavaScript const input = require('fs').readFileSync('/dev/stdin').toString(); const N = +input; const spaceStart = N - 1; //4 const resultLength = 2 * N - 1; //9 for (let i = spaceStart; i >= 0; i--) { let resultArr = new Array(resultLength); let star = resultLength - (2 * i); resultArr.fill(" ", 0, i); resultArr.fill("*", i, i + star); console.log(resultArr.join("")); } for (let i = 1; i < spaceStart + 1;..
[๋ฐฑ์ค€/Node.js] 5622๋ฒˆ ๋‹ค์ด์–ผ || ํ’€์ด JavaScript ์ฒ˜์Œ์—” ๋‹จ์ˆœํ•˜๊ฒŒ switch ๋ฌธ์„ ๊ฐ€์ง€๊ณ  ์“ฐ๋‹ค๊ฐ€ ํ˜„ํƒ€๊ฐ€์˜ด. ๊ทธ๋ž˜์„œ if๋ฌธ์œผ๋กœ ์•„์Šคํ‚ค ๋ฌธ์ž๋กœ ๋ณ€ํ™˜ํ›„ ๋ฒ”์œ„ ์ง€์ •ํ•ด์„œ ํ•˜๋‹ค๊ฐ€ ๋˜๋‹ค์‹œ ํ˜„ํƒ€๊ฐ€ ์˜ด. (๊ฒŒ๋‹ค๊ฐ€ ํ‹€๋ฆผ) ์ด๋ ‡๊ฒŒ ๋ฐ–์— ๋ชปํ’€์ง€ ์•Š์„ ํ…๋ฐ...?? ์•ŒํŒŒ๋ฒณ์€ ๋Œ€๋ถ€๋ถ„ 3๊ฐœ์”ฉ ๋‚˜๋ˆ ์ ธ ์žˆ๊ณ , (7๋ฒˆ์ด๋ž‘ 9๋ฒˆ๋งŒ 4๊ฐœ์”ฉ) index๋กœ ์—ฐ๊ด€์‹œํ‚ค๋ฉด ๋  ๊ฑฐ ๊ฐ™์€๋ฐ ๋ผ๋Š” ์ƒ๊ฐ์ด ๋“ค์—ˆ๋‹ค. ์•ŒํŒŒ๋ฒณ ์ „์ฒด๋ฅผ ๋ฐฐ์—ด๋กœ ๋งŒ๋“  ํ›„ index๋ฅผ ๋ณด๋ฉด ์ด๋Ÿฐ ์‹์ด๋‹ค. [ 'A', 0 ], [ 'B', 1 ], [ 'C', 2 ], [ 'D', 3 ], [ 'E', 4 ], [ 'F', 5 ], [ 'G', 6 ], [ 'H', 7 ], [ 'I', 8 ], [ 'J', 9 ], [ 'K', 10 ], [ 'L', 11 ], [ 'M', 12 ], [ 'N', 13 ], [ 'O', 14 ], ..
[๋ฐฑ์ค€/Node.js] 1546๋ฒˆ ํ‰๊ท  || ํ’€์ด JavaScript let input = require('fs').readFileSync('/dev/stdin').toString().trim().split("\n").map(i => i.split(" ")); const n = input[0]; const subs = input[1]; const m = Math.max(...subs); const raiseScore = (subs, maxSub) => { let newScores = subs.map(v => v / maxSub * 100); return newScores.reduce((sum, v) => sum + v) / n; } console.log(raiseScore(subs, m)); ๋ฌธ์ œ ํ’€์ด๋ฅผ ํ•  ๋•Œ ๋จผ์ € ์ฝ”๋“œ๋ฅผ ์“ฐ์ง€ ๋ง๊ณ , ์–ด๋–ค ์ ˆ์ฐจ๋กœ ๊ฐ’์„ ๊ตฌํ• ์ง€ ๋จผ์ € ์“ฐ๋Š” ..
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/Javascript] [level.0] k์˜ ๊ฐœ์ˆ˜ || ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ๋ฒ”์œ„ ๋‚ด์—์„œ ์ฃผ์–ด์ง„ k์˜ ๊ฐœ์ˆ˜๊ฐ€ ๋ช‡๊ฐœ ๋“ค์–ด๊ฐ€๋Š”์ง€ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“œ๋Š” ๋ฌธ์ œ. function solution(i, j, k) { let range = []; for (let index = i; index < j + 1; index++) { range.push(index); } const string = range.join(""); const minus = string.replaceAll(k, ""); return string.length - minus.length; } ์ „์ฒด๋ฅผ ๋ฌธ์ž๋กœ ๋งŒ๋“ค๊ณ , ๊ฑฐ๊ธฐ์—์„œ k๋ฅผ ์ œ๊ฑฐํ•œ ๋ฌธ์ž๋ฅผ ๋บ€ ์ˆ˜๊ฐ€ k ์˜ ๊ฐœ์ˆ˜๋‹ค! ํ•˜๋Š” ์‹์œผ๋กœ ๊ตฌํ–ˆ๋Š”๋ฐ, function solution(i, j, k) { let a =''; for(i;i
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/Javascript] [level.0] ๊ฐ€๊นŒ์šด ์ˆ˜ || ์ฝ”๋”ฉํ…Œ์ŠคํŠธ n-v ์˜ ์ ˆ๋Œ€๊ฐ’์„ ๊ตฌํ•ด์„œ ์ ˆ๋Œ€๊ฐ’์ด ๊ฐ€์žฅ ์ž‘์€ ์ˆ˜๋ฅผ ์ฐพ์œผ๋ฉด ๋œ๋‹ค. ๊ทผ๋ฐ ์ ˆ๋Œ€๊ฐ’ ํ•จ์ˆ˜๊ฐ€ ์žˆ๋Š” ์ค„ ๋ชจ๋ฅด๊ณ ! function solution(array, n) { const gapArr = array.map(v => n - v > 0 ? n - v : -(n - v)); const minGap = Math.min(...gapArr); const minGapValueArr = array.filter(v => n - v === minGap || v - n === minGap); const result = minGapValueArr.length > 1 ? Math.min(...minGapValueArr) : minGapValueArr[0]; return result; }; ๋จผ์ € ์ ˆ๋Œ€๊ฐ’์„ ๊ตฌํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ์งœ๋ฒ„๋ ธ์ง€ ๋ญ”๊ฐ€..
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/Javascript] [level.0] 2์ฐจ์›์œผ๋กœ ๋งŒ๋“ค๊ธฐ || ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์ฃผ์–ด์ง„ n ์˜ ์ˆ˜๋งŒํผ์˜ ๋ฐฐ์—ด์„ ์ƒˆ๋กœ ์ƒ์„ฑํ•ด ํ•˜๋‚˜์˜ ๋ฐฐ์—ด์„ ๋งŒ๋“œ๋Š” ๋ฌธ์ œ. function solution(num_list, n) { let resultArr = []; for (let k = 0; k ์ฆ‰, ๋‹ค ์—†์–ด์งˆ ๋•Œ๊นŒ์ง€ 0~ n๊นŒ์ง€์˜ ๋ฐฐ์—ด์„ splice ํ•ด์„œ ์ƒˆ๋กœ์šด ๋ฐฐ์—ด๋กœ ๋„ฃ์—ˆ๋‹ค. ๋งค๋ฒˆ for๋ฌธ๋งŒ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝํ–ฅ์ด ์žˆ๋‹ค. while ๋ฌธ์„ ์ž˜ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์œผ๋ฉด ์ข‹์€๋ฐ, ๋Š˜ ์‚ฌ์šฉํ•  ๋•Œ๋งˆ๋‹ค ๋ฌดํ•œ๋ฃจํ”„๊ฐ€ ๋‚˜์˜ฌ๊นŒ๋ด ๊ฑฑ์ •๋œ๋‹ค. ๐Ÿ˜“ ์ฐธ/๊ฑฐ์ง“์ด ํ™•์‹คํ•˜๊ฒŒ ๊ตฌ๋ถ„๋˜๊ฒŒ ํ•˜๋Š” ์—ฐ์Šต์„ ํ•ด์•ผ๊ฒ ๋‹ค.
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/Javascript] [level.0] ์ง๊ฐ์‚ผ๊ฐํ˜• ์ถœ๋ ฅํ•˜๊ธฐ || ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์ž…๋ฌธ const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); let input = [3]; rl.on('line', function (line) { input = line.split(' '); }).on('close', function () { const star = Number(input[0]); for (let i = 1; i
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/Javascript] [level.0] ์™ธ๊ณ„ํ–‰์„ฑ์˜ ๋‚˜์ด || ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์ž…๋ฌธ ์•„์Šคํ‚ค ์ฝ”๋“œ๋กœ " ์ˆซ์ž -> ๋ฌธ์ž " ๋กœ ๋ณ€ํ™˜ํ•˜๊ธฐ function solution(age) { const arr = String(age).split("").map(v => String.fromCharCode(Number(v) + 97)) return arr.join(""); } https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode String.fromCharCode() - JavaScript | MDN String.fromCharCode() ๋ฉ”์„œ๋“œ๋Š” UTF-16 ์ฝ”๋“œ ์œ ๋‹›์˜ ์‹œํ€€์Šค๋กœ๋ถ€ํ„ฐ ๋ฌธ์ž์—ด์„ ์ƒ์„ฑํ•ด ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. developer.mozilla.org ์•„์Šคํ‚ค ์ฝ”๋“œ์—์„œ a ๊ฐ€ 97 ์ด..

728x90
๋ฐ˜์‘ํ˜•