From 2746879de097f91b28beacbeb09367ad6f5b3352 Mon Sep 17 00:00:00 2001 From: HaeJungg Date: Tue, 9 Apr 2024 13:00:28 +0900 Subject: [PATCH] =?UTF-8?q?=ED=94=84=EB=A1=9C=EA=B7=B8=EB=9E=98=EB=A8=B8?= =?UTF-8?q?=EC=8A=A4=2010=ED=8E=98=EC=9D=B4=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...34\353\240\245\355\225\230\352\270\260.js" | 17 +++++++++++ ...75\354\232\260\354\235\230\354\210\230.js" | 13 +++++++++ ...70\353\246\274\355\231\225\353\214\200.js" | 14 ++++++++++ ...20\354\210\230\354\235\230\355\225\251.js" | 5 ++++ ...70\354\235\270\354\204\261\352\263\265.js" | 21 ++++++++++++++ ...30\354\210\230\353\275\221\352\270\260.js" | 15 ++++++++++ ...71\354\263\220\354\223\260\352\270\260.js" | 5 ++++ ...04\354\202\260\355\225\230\352\270\260.js" | 16 +++++++++++ ...10\353\222\244\354\247\221\352\270\260.js" | 13 +++++++++ ...4\353\247\214\353\223\244\352\270\2606.js" | 21 ++++++++++++++ ...354\204\261\354\241\260\352\261\264(2).js" | 8 ++++++ ...4\352\260\204\354\277\274\353\246\2542.js" | 21 ++++++++++++++ ...00\354\213\253\354\226\264\354\232\224.js" | 28 +++++++++++++++++++ ...04\354\226\264\354\202\254\354\240\204.js" | 12 ++++++++ ...75\354\230\244\353\245\270\354\252\275.js" | 16 +++++++++++ ...4_\353\247\214\353\223\244\352\270\260.js" | 19 +++++++++++++ ...64\353\254\270\354\236\220\354\227\264.js" | 12 ++++++++ ...64\354\236\220\353\245\264\352\270\260.js" | 3 ++ ...64\352\265\254\355\225\230\352\270\260.js" | 9 ++++++ ...60\354\235\230\354\242\214\355\221\234.js" | 24 ++++++++++++++++ 20 files changed, 292 insertions(+) create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/a\354\231\200b\354\266\234\353\240\245\355\225\230\352\270\260.js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\352\265\254\354\212\254\354\235\204\353\202\230\353\210\204\353\212\224\352\262\275\354\232\260\354\235\230\354\210\230.js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\352\267\270\353\246\274\355\231\225\353\214\200.js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\221\220\354\210\230\354\235\230\355\225\251.js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\241\234\352\267\270\354\235\270\354\204\261\352\263\265.js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\254\264\354\236\221\354\234\204\353\241\234k\352\260\234\354\235\230\354\210\230\353\275\221\352\270\260.js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\254\270\354\236\220\354\227\264\352\262\271\354\263\220\354\223\260\352\270\260.js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\254\270\354\236\220\354\227\264\352\263\204\354\202\260\355\225\230\352\270\260.js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\254\270\354\236\220\354\227\264\354\227\254\353\237\254\353\262\210\353\222\244\354\247\221\352\270\260.js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\260\260\354\227\264\353\247\214\353\223\244\352\270\2606.js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\202\274\352\260\201\355\230\225\354\235\230\354\231\204\354\204\261\354\241\260\352\261\264(2).js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\210\230\354\227\264\352\263\274\352\265\254\352\260\204\354\277\274\353\246\2542.js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\230\201\354\226\264\352\260\200\354\213\253\354\226\264\354\232\224.js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\231\270\352\263\204\354\226\264\354\202\254\354\240\204.js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\231\274\354\252\275\354\230\244\353\245\270\354\252\275.js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\240\225\354\202\254\352\260\201\355\230\225\354\234\274\353\241\234_\353\247\214\353\223\244\352\270\260.js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\241\260\352\261\264\353\254\270\354\236\220\354\227\264.js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\242\205\354\235\264\354\236\220\353\245\264\352\270\260.js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\247\201\354\202\254\352\260\201\355\230\225_\353\204\223\354\235\264\352\265\254\355\225\230\352\270\260.js" create mode 100644 "\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\272\220\353\246\255\355\204\260\354\235\230\354\242\214\355\221\234.js" diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/a\354\231\200b\354\266\234\353\240\245\355\225\230\352\270\260.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/a\354\231\200b\354\266\234\353\240\245\355\225\230\352\270\260.js" new file mode 100644 index 0000000..8e4ea8a --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/a\354\231\200b\354\266\234\353\240\245\355\225\230\352\270\260.js" @@ -0,0 +1,17 @@ +const readline = require("readline"); +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, +}); + +function printFormat(a, b) { + console.log(`a = ${a}\nb = ${b}`); +} + +let input = []; + +rl.on("line", function (line) { + input = line.split(" ").map(Number); + printFormat(input[0], input[1]); + rl.close(); +}); diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\352\265\254\354\212\254\354\235\204\353\202\230\353\210\204\353\212\224\352\262\275\354\232\260\354\235\230\354\210\230.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\352\265\254\354\212\254\354\235\204\353\202\230\353\210\204\353\212\224\352\262\275\354\232\260\354\235\230\354\210\230.js" new file mode 100644 index 0000000..69c4c87 --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\352\265\254\354\212\254\354\235\204\353\202\230\353\210\204\353\212\224\352\262\275\354\232\260\354\235\230\354\210\230.js" @@ -0,0 +1,13 @@ +function solution(balls, share) { + if (share > balls) { + return 0; + } + + let answer = 1; + for (let i = 1; i <= share; i++) { + answer *= balls - i + 1; + answer /= i; + } + + return answer; +} diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\352\267\270\353\246\274\355\231\225\353\214\200.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\352\267\270\353\246\274\355\231\225\353\214\200.js" new file mode 100644 index 0000000..3c14cf1 --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\352\267\270\353\246\274\355\231\225\353\214\200.js" @@ -0,0 +1,14 @@ +function solution(picture, k) { + const answer = []; + for (let i = 0; i < picture.length; i++) { + const row = picture[i]; + const enlargedRow = row + .split("") + .map((char) => char.repeat(k)) + .join(""); + for (let j = 0; j < k; j++) { + answer.push(enlargedRow); + } + } + return answer; +} diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\221\220\354\210\230\354\235\230\355\225\251.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\221\220\354\210\230\354\235\230\355\225\251.js" new file mode 100644 index 0000000..dbafa8f --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\221\220\354\210\230\354\235\230\355\225\251.js" @@ -0,0 +1,5 @@ +function solution(a, b) { + const sum = BigInt(a) + BigInt(b); + + return sum.toString(); +} diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\241\234\352\267\270\354\235\270\354\204\261\352\263\265.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\241\234\352\267\270\354\235\270\354\204\261\352\263\265.js" new file mode 100644 index 0000000..2e3e599 --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\241\234\352\267\270\354\235\270\354\204\261\352\263\265.js" @@ -0,0 +1,21 @@ +function solution(id_pw, db) { + const [inputId, inputPw] = id_pw; + let idMatch = false; + + for (let i = 0; i < db.length; i++) { + const [dbId, dbPw] = db[i]; + + if (inputId === dbId) { + idMatch = true; + if (inputPw === dbPw) { + return "login"; + } else { + return "wrong pw"; + } + } + } + + if (!idMatch) { + return "fail"; + } +} diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\254\264\354\236\221\354\234\204\353\241\234k\352\260\234\354\235\230\354\210\230\353\275\221\352\270\260.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\254\264\354\236\221\354\234\204\353\241\234k\352\260\234\354\235\230\354\210\230\353\275\221\352\270\260.js" new file mode 100644 index 0000000..cf9bda6 --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\254\264\354\236\221\354\234\204\353\241\234k\352\260\234\354\235\230\354\210\230\353\275\221\352\270\260.js" @@ -0,0 +1,15 @@ +function solution(arr, k) { + const uniqueSet = new Set(); + + for (const num of arr) { + uniqueSet.add(num); + } + + const uniqueArr = [...uniqueSet]; + + while (uniqueArr.length < k) { + uniqueArr.push(-1); + } + + return uniqueArr.slice(0, k); +} diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\254\270\354\236\220\354\227\264\352\262\271\354\263\220\354\223\260\352\270\260.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\254\270\354\236\220\354\227\264\352\262\271\354\263\220\354\223\260\352\270\260.js" new file mode 100644 index 0000000..3ea55d9 --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\254\270\354\236\220\354\227\264\352\262\271\354\263\220\354\223\260\352\270\260.js" @@ -0,0 +1,5 @@ +function solution(my_string, overwrite_string, s) { + const start = my_string.slice(0, s); + const end = my_string.slice(s + overwrite_string.length); + return start + overwrite_string + end; +} diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\254\270\354\236\220\354\227\264\352\263\204\354\202\260\355\225\230\352\270\260.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\254\270\354\236\220\354\227\264\352\263\204\354\202\260\355\225\230\352\270\260.js" new file mode 100644 index 0000000..a6cba9a --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\254\270\354\236\220\354\227\264\352\263\204\354\202\260\355\225\230\352\270\260.js" @@ -0,0 +1,16 @@ +function solution(my_string) { + const string = my_string.split(" "); + let answer = parseInt(string[0]); + + for (let i = 1; i < string.length; i += 2) { + const op = string[i]; + const operand = parseInt(string[i + 1]); + if (op === "+") { + answer += operand; + } else if (op === "-") { + answer -= operand; + } + } + + return answer; +} diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\254\270\354\236\220\354\227\264\354\227\254\353\237\254\353\262\210\353\222\244\354\247\221\352\270\260.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\254\270\354\236\220\354\227\264\354\227\254\353\237\254\353\262\210\353\222\244\354\247\221\352\270\260.js" new file mode 100644 index 0000000..233c557 --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\254\270\354\236\220\354\227\264\354\227\254\353\237\254\353\262\210\353\222\244\354\247\221\352\270\260.js" @@ -0,0 +1,13 @@ +function solution(my_string, queries) { + for (let i = 0; i < queries.length; i++) { + const [start, end] = queries[i]; + const reverse = my_string + .substring(start, end + 1) + .split("") + .reverse() + .join(""); + my_string = + my_string.substring(0, start) + reverse + my_string.substring(end + 1); + } + return my_string; +} diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\260\260\354\227\264\353\247\214\353\223\244\352\270\2606.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\260\260\354\227\264\353\247\214\353\223\244\352\270\2606.js" new file mode 100644 index 0000000..7702a3e --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\353\260\260\354\227\264\353\247\214\353\223\244\352\270\2606.js" @@ -0,0 +1,21 @@ +function solution(arr) { + const stk = []; + let i = 0; + + while (i < arr.length) { + if (stk.length === 0) { + stk.push(arr[i]); + i++; + } else { + if (stk[stk.length - 1] === arr[i]) { + stk.pop(); + i++; + } else { + stk.push(arr[i]); + i++; + } + } + } + + return stk.length > 0 ? stk : [-1]; +} diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\202\274\352\260\201\355\230\225\354\235\230\354\231\204\354\204\261\354\241\260\352\261\264(2).js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\202\274\352\260\201\355\230\225\354\235\230\354\231\204\354\204\261\354\241\260\352\261\264(2).js" new file mode 100644 index 0000000..a398927 --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\202\274\352\260\201\355\230\225\354\235\230\354\231\204\354\204\261\354\241\260\352\261\264(2).js" @@ -0,0 +1,8 @@ +function solution(sides) { + const [a, b] = sides.sort((a, b) => a - b); + + const minPossibleSide = b - a + 1; + const maxPossibleSide = a + b - 1; + + return maxPossibleSide - minPossibleSide + 1; +} diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\210\230\354\227\264\352\263\274\352\265\254\352\260\204\354\277\274\353\246\2542.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\210\230\354\227\264\352\263\274\352\265\254\352\260\204\354\277\274\353\246\2542.js" new file mode 100644 index 0000000..35795fd --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\210\230\354\227\264\352\263\274\352\265\254\352\260\204\354\277\274\353\246\2542.js" @@ -0,0 +1,21 @@ +function solution(arr, queries) { + const result = []; + + for (const query of queries) { + const [start, end, k] = query; + + const sortedSubArr = arr.slice(start, end + 1).sort((a, b) => a - b); + let minGreater = -1; + + for (const num of sortedSubArr) { + if (num > k) { + minGreater = num; + break; + } + } + + result.push(minGreater); + } + + return result; +} diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\230\201\354\226\264\352\260\200\354\213\253\354\226\264\354\232\224.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\230\201\354\226\264\352\260\200\354\213\253\354\226\264\354\232\224.js" new file mode 100644 index 0000000..e9e4081 --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\230\201\354\226\264\352\260\200\354\213\253\354\226\264\354\232\224.js" @@ -0,0 +1,28 @@ +function solution(numbers) { + const number = { + zero: 0, + one: 1, + two: 2, + three: 3, + four: 4, + five: 5, + six: 6, + seven: 7, + eight: 8, + nine: 9, + }; + + let result = ""; + let currentWord = ""; + + for (let i = 0; i < numbers.length; i++) { + currentWord += numbers[i]; + + if (number.hasOwnProperty(currentWord)) { + result += number[currentWord]; + currentWord = ""; + } + } + + return parseInt(result); +} diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\231\270\352\263\204\354\226\264\354\202\254\354\240\204.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\231\270\352\263\204\354\226\264\354\202\254\354\240\204.js" new file mode 100644 index 0000000..49e8c53 --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\231\270\352\263\204\354\226\264\354\202\254\354\240\204.js" @@ -0,0 +1,12 @@ +function solution(spell, dic) { + const spellWord = spell.sort().join(""); + + for (let i = 0; i < dic.length; i++) { + const dicWord = dic[i].split("").sort().join(""); + if (spellWord === dicWord) { + return 1; + } + } + + return 2; +} diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\231\274\354\252\275\354\230\244\353\245\270\354\252\275.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\231\274\354\252\275\354\230\244\353\245\270\354\252\275.js" new file mode 100644 index 0000000..3e2d22d --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\231\274\354\252\275\354\230\244\353\245\270\354\252\275.js" @@ -0,0 +1,16 @@ +function solution(str_list) { + let leftIndex = str_list.indexOf("l"); + let rightIndex = str_list.indexOf("r"); + + if (leftIndex === -1 && rightIndex === -1) { + return []; + } else if (leftIndex !== -1 && rightIndex !== -1) { + return leftIndex < rightIndex + ? str_list.slice(0, leftIndex) + : str_list.slice(rightIndex + 1); + } else if (leftIndex !== -1) { + return str_list.slice(0, leftIndex); + } else { + return str_list.slice(rightIndex + 1); + } +} diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\240\225\354\202\254\352\260\201\355\230\225\354\234\274\353\241\234_\353\247\214\353\223\244\352\270\260.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\240\225\354\202\254\352\260\201\355\230\225\354\234\274\353\241\234_\353\247\214\353\223\244\352\270\260.js" new file mode 100644 index 0000000..1568bec --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\240\225\354\202\254\352\260\201\355\230\225\354\234\274\353\241\234_\353\247\214\353\223\244\352\270\260.js" @@ -0,0 +1,19 @@ +function solution(arr) { + const rowCount = arr.length; + const colCount = arr[0].length; + + if (rowCount > colCount) { + for (let i = 0; i < rowCount; i++) { + while (arr[i].length < rowCount) { + arr[i].push(0); + } + } + } else if (colCount > rowCount) { + while (arr.length < colCount) { + const newRow = new Array(colCount).fill(0); + arr.push(newRow); + } + } + + return arr; +} diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\241\260\352\261\264\353\254\270\354\236\220\354\227\264.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\241\260\352\261\264\353\254\270\354\236\220\354\227\264.js" new file mode 100644 index 0000000..051d4fc --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\241\260\352\261\264\353\254\270\354\236\220\354\227\264.js" @@ -0,0 +1,12 @@ +function solution(ineq, eq, n, m) { + if ( + (ineq === "<" && eq === "=" && n <= m) || + (ineq === ">" && eq === "=" && n >= m) || + (ineq === "<" && eq === "!" && n < m) || + (ineq === ">" && eq === "!" && n > m) + ) { + return 1; + } else { + return 0; + } +} diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\242\205\354\235\264\354\236\220\353\245\264\352\270\260.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\242\205\354\235\264\354\236\220\353\245\264\352\270\260.js" new file mode 100644 index 0000000..80a1c07 --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\242\205\354\235\264\354\236\220\353\245\264\352\270\260.js" @@ -0,0 +1,3 @@ +function solution(M, N) { + return M * N - 1; +} diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\247\201\354\202\254\352\260\201\355\230\225_\353\204\223\354\235\264\352\265\254\355\225\230\352\270\260.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\247\201\354\202\254\352\260\201\355\230\225_\353\204\223\354\235\264\352\265\254\355\225\230\352\270\260.js" new file mode 100644 index 0000000..ea0aa2d --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\247\201\354\202\254\352\260\201\355\230\225_\353\204\223\354\235\264\352\265\254\355\225\230\352\270\260.js" @@ -0,0 +1,9 @@ +function solution(dots) { + const xCoords = dots.map((dot) => dot[0]); + const yCoords = dots.map((dot) => dot[1]); + + const width = Math.max(...xCoords) - Math.min(...xCoords); + const height = Math.max(...yCoords) - Math.min(...yCoords); + + return width * height; +} diff --git "a/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\272\220\353\246\255\355\204\260\354\235\230\354\242\214\355\221\234.js" "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\272\220\353\246\255\355\204\260\354\235\230\354\242\214\355\221\234.js" new file mode 100644 index 0000000..c80921c --- /dev/null +++ "b/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/0\353\213\250\352\263\204/\354\272\220\353\246\255\355\204\260\354\235\230\354\242\214\355\221\234.js" @@ -0,0 +1,24 @@ +function solution(keyinput, board) { + let position = [0, 0]; + const maxX = Math.floor(board[0] / 2); + const maxY = Math.floor(board[1] / 2); + + keyinput.forEach((key) => { + switch (key) { + case "up": + if (position[1] < maxY) position[1] += 1; + break; + case "down": + if (position[1] > -maxY) position[1] -= 1; + break; + case "left": + if (position[0] > -maxX) position[0] -= 1; + break; + case "right": + if (position[0] < maxX) position[0] += 1; + break; + } + }); + + return position; +}