๋ฐ์ํ ๐ ์๊ณ ๋ฆฌ์ฆ65 [๋ฐฑ์ค] JS/ 10808 ์ํ๋ฒณ ๊ฐ์ ๋ด ํ์ด const fs = require('fs'); let input = (fs.readFileSync('./test') + '').toString().trim().split(''); let ans = new Array(26).fill(0); input.map((alpha) => { let alpha2Ascii = alpha.charCodeAt(0); ans[alpha2Ascii - 97] += 1; }); console.log(ans.join(' ')); ์ ๋ง ๋จ์ํ ๋ฐ์ ๋ฌธ์์ด์ ๋ฐฐ์ด๋ก ๋๋ฉฐ Ascii๋ก ๋ฐ๊ฟ์ฃผ๊ณ ํด๋น ๋ฐฐ์ด์ idx-97 (a = 97)์ ๋ฃ์ด์ฃผ๊ธฐ! ๋ค๋ฅธ ํ์ด const s = require("fs").readFileSync("/dev/stdin").toString().split(.. 2021. 9. 30. [๋ฐฑ์ค] JS/ 4949 ๊ท ํ์กํ ์ธ์ โ.์ค์ ๋ฐฑ์ค ํ์ด์์๋ fs.readFileSync('./test') -> fs.readFileSync('./dev/stdin') ์ด๋ ๊ฒ ๊ณ ์ณ์ ์๊ฐํด์ฃผ์ธ์ ์ฒ์ ํ์ด๋ ์์ ํ ์๋ชป ์๊ฐํ๋ค. ๋๊ฐ์ ๊ฐ์๋ง ๋ง์ผ๋ฉด ๋๋ค๊ณ ์๊ฐํด์ ์ ๊ทํํ์์ผ๋ก ์ ์ฑ์ค๋ฝ๊ฒ ์ด์ํ ์ฝ๋๋ฅผ ์จ๋ด๋ ค๊ฐ๋ค..^^ ์ฒ์ ํ์ด ( ๋ฐฉํฅ ์์ ์๋ชป ) const fs = require('fs'); let input = (fs.readFileSync('./test') + '').toString().trim().split('.'); input.pop(); input.pop(); console.log(input); const regL = /\[/g; const regR = /\[/g; const regl = /\(/g; const regr.. 2021. 9. 29. [๋ฐฑ์ค] JS/ 10798 ์ธ๋ก์ฝ๊ธฐ ๋ด ํ์ด1(์ค๋ต) const fs = require('fs'); let input = (fs.readFileSync('./dev/stdin') + '').split('\n'); let ans = ''; const wordArr = input.map((i) => i.split('')); const turnCnt = wordArr.length; let allCnt = 0; while (allCnt { if (word[0] !== undefined) ans += word.shift(); else allCnt += 1; }); } console.log(ans); 1. ๊ธ์๋ฅผ ์์ ๊ฐ์ ์ด์ค๋ฐฐ์ด๋ก ์์ฑ 2. ์ด ๋ฐฐ์ด์ ๊ธธ์ด => ๊ฐ์๋ก ๋๊ณ 3.. 2021. 9. 29. [๋ฐฑ์ค] JS/ 14561 ํ๋ฌธ ํ์ค์ ๋ฐ์๋ค์ฌ์ผ ํ๋ค. ๋ฐ๋ก Node.js ๋ก ์๊ณ ๋ฆฌ์ฆ์ ์ฐ์ตํด์ผ ํ๋ค๋ ์ฌ์ค์! ๋ด ํ์ด (์ ๋ต) const fs = require('fs'); const input = fs.readFileSync('/dev/stdin').toString().trim().split('\n').map((e) => e.split(' ').map(Number));; input.shift(); const nArr = input.map((arr) => { const [num, n] = [arr[0], arr[1]]; return num.toString(n); }); const isPalindrome = (num) => { let lenNum = num.length; let hLenNum = Math.floor(num.leng.. 2021. 9. 27. [codility] JS Lv4-3 MaxCounter ๐ 4-3 MaxCounter ๋ด ํ์ด 1 (์ค๋ต) function solution(N, A) { let ans = new Array(N).fill(0); A.forEach((a) => { if (a { let idx = a - 1; if (a 2๊ฐ์ง testcase๊ฐ ์ค๋ต์ด ๋์๋ค. ๋ดํ์ด 3 (100%) function solution(N, A) { let ans = new Array(N).fill(0); let maxNum = 0; let last = 0; A.forEach((a) => { let idx = a - 1; if (a { if(a < last){ ans[idx] = last } }) return ans; } Math.max ํ๋ ๋ถ๋ถ์ ์ง์ฐ๊ธฐ ์ํด last ๋ผ๋ ๋ณ์๋ฅผ ์ถ๊ฐํด A๋ฅผ ๋๋ฉฐ.. 2021. 9. 24. [codility] JS Lv4-1 ForgRiverOne ๐ 4-1 ForgRiverOne ๋ดํ์ด 1 (72%) ์๊ฐ์ด๊ณผ function solution(X, A) { ans = -1; let idxArr = new Array(X).fill(0); const isContinue = (arr) => { const idx = arr.findIndex((ele) => ele === 0); if (idx >= 0) return false; else return true; }; for (let i = 0; i { let ans = true for (let i = 0; i < arr.length; i++) { if (arr[i] === 0) { ans = false break } } return ans }; for (let i = 0; i 2021. 9. 18. [codility] JS Lv3-3 TapeEquilibrium ๐ STEP 3-3 ) TapeEquilibrium ๋ด ํ์ด1 ( 46% ) function solution(A) { P = A.length const getSumArr = (arr)=>arr.reduce((prev,curr)=>prev+curr) let ans = 1000 for (let i=1 ; i< P ; i++){ const first = A.slice(0,i) const second = A.slice(i,P+1) diff = Math.abs(getSumArr(first)-getSumArr(second)) ans = Math.min (diff,ans) } return ans } 1) ๋ฐ๋ณต๋ฌธ์ ๋๋ฉฐ ํด๋น ์ซ์์ ๋ฒ์๊น์ง slicingํ ๋ฐฐ์ด์ ๊ตฌํ๋ค 2) ๊ทธ ๊ฐ์ diff์ ๋น๊ตํด์ min์ ๊ตฌํ.. 2021. 9. 17. [์ด์ฝ๋ค] ๊ทธ๋ฆฌ๋-๊ธฐ์ถ๋ฌธ์ P.314 ๋ง๋ค ์ ์๋ ๊ธ์ก ๋ด ํ์ด n = int(input()) money = list(map(int,input().split())) maxM = max(money) confirm = [0 for i in range(10000)] print(confirm) for i in range(len(money)): for j in range(i+1,len(money)): confirm[i+j] = 1 print(confirm.find(0,1)) confirm์ด๋ผ๋ ์ต๋๊ฐ๊น์ง์ 0์ผ๋ก ์ฐฌ ๋ฐฐ์ด์ ๋ง๋ค๊ณ ์ด์ค for๋ฌธ์ ๋์ ๋ชจ๋ ๊ฐ์ ๋ํด์ ๊ทธ ์ธ๋ฑ์ค์1์ ๋ฃ์ด์ค ํ์ 0 ์ธ๋ฑ์ค๋ฅผ ์ ์ธํ 0์ด ๋์จ ์ฒซ๋ฒ์งธ ์ธ๋ฑ์ค๋ฅผ ์ฐพ์ผ๋ ค ํ์ง๋ง ์๋ชปํ๋ค. ์ ๋ต ํ์ด n = int(input()) money = list(map.. 2021. 8. 31. [๋ฐฑ์ค] ํ์ด์ฌ/ 10163 ์์ข ์ด ๐ 10163 ์์ข ์ด ๋ด ํ์ด n = int(input()) paper = [] for i in range(n): paper.append(list(map(int,input().split()))) place = [[0]*1001 for _ in range(1001)] for i,p in enumerate(paper): cnt=0 [row,col,area,height] = p for r in range(row,row+area): for c in range(col,col+height): place[r][c]=i+1 for i in range(n): cnt=0 for p in place: cnt += p.count(i+1) print(cnt) ๋จ์ ์ธ ์๋ก 2 0 0 10 10 2 2 6 6 ์ ์ ๋ ฅํ์ ์ ์ฒซ๋ฒ.. 2021. 8. 29. ์ด์ 1 2 3 4 5 6 ยทยทยท 8 ๋ค์ ๋ฐ์ํ