본문 바로가기

[BAEKJOON] 단어 정렬 (1181번) // const input = require("fs").readFileSync("/dev/stdin").toString().trim().split("\n"); const input = require("fs").readFileSync("testCase/testCase.txt").toString().trim().split("\r\n"); function sortWords(input) { input.shift(); let sortArr = input.sort().sort((x, y) => x.length - y.length); let answerArr = []; for(let i = 0; i < sortArr.length; i++) { if(answerArr.includes(sortArr[i])) { cont..
[BAEKJOON] 달팽이는 올라가고 싶다 (2869번) // const testCase = require("fs").readFileSync("/dev/stdin").toString().trim().split(" "); // const testCase = "2 1 5".toString().trim().split(" "); // const testCase = "5 1 6".toString().trim().split(" "); const testCase = "100 99 1000000000".toString().trim().split(" "); function snailWantsToClimb(testCase) { let dayTime = testCase[0]; let nightTime = testCase[1]; let height = testCase[2]; let..
[BAEKJOON] 셀프 넘버 (4673번) function selfNumber() { let tempArr = []; let answer = []; for (let i = 1; i
[BAEKJOON] 다이얼 (5622번) // const input = require("fs").readFileSync("/dev/stdin").toString().trim().split(""); const input = "WA".toString().trim().split(""); // const input = "UNUCIC".toString().trim().split(""); function dial(input) { let phoneDial = { 2 : "ABC", 3 : "DEF", 4 : "GHI", 5 : "JKL", 6 : "MNO", 7 : "PQRS", 8 : "TUV", 9 : "WXYZ", }; let answer = 0; for(let i = 0; i < input.length; i++) { for(let j = 2; j
[BAEKJOON] 한수 (1065번) // const input = require("fs").readFileSync("/dev/stdin").toString(); const input = "500".toString(); function arithmeticSequence(input) { let testCase = Number(input); let answer = 0; for(let i = 1; i
[BAEKJOON] 제로 (10773번) // const input = require("fs").readFileSync("/dev/stdin").toString().trim().split("\r\n"); const input = require("fs").readFileSync("testCase/testCase.txt").toString().trim().split("\r\n"); function zero(input) { let testCaseCnt = input[0]; let a = []; for(let i = 1; i { answer += +element; }) return console.log(answer); } } zero(input);
[BAEKJOON] 평균은 넘겠지 (4344번) // const input = require("fs").readFileSync("/dev/stdin").toString().trim().split(" "); const input = require("fs").readFileSync("testCase/testCase.txt").toString().trim().split("\n"); function iGuessOverTheAvg(input) { for(let i = 1; i avg) overAvgCnt++; } console.log(`${(overAvgCnt / testCase.length * 100).toFixed(3)}%`); } } iGuessOverTheAvg(input);
[BAEKJOON] 팰린드롬수 (1259번) // const testCase = require("fs").readFileSync("/dev/stdin").toString().trim().split(" "); const testCase = "121\n1231\n12421\n0".toString().trim().split("\n"); function palindromeString(testCase) { let reverseTestCase = []; for(let i = 0; i