Skip to content

Commit

Permalink
231128 문제 업로드 (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyeple authored Dec 12, 2023
1 parent 2e45850 commit 0d228d7
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Hyeple/231128/boj_4949.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const fs = require("fs");

const input = fs.readFileSync("/dev/stdin").toString().trim().split("\n");

for (let s of input) {
if (s === ".") {
break;
}

let stack = [];
let check = true;

for (let i = 0; i < s.length; i++) {
if (s[i] === "(" || s[i] === "[") {
stack.push(s[i]);
} else if (s[i] === ")") {
if (stack.length && stack[stack.length - 1] === "(") {
stack.pop();
} else {
check = false;
break;
}
} else if (s[i] === "]") {
if (stack.length && stack[stack.length - 1] === "[") {
stack.pop();
} else {
check = false;
break;
}
}
}

if (check && stack.length === 0) {
console.log("yes");
} else {
console.log("no");
}
}
18 changes: 18 additions & 0 deletions Hyeple/231128/pro_155651.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function solution(bookTime) {
const time = Array(60 * 24).fill(0);

for (const [s, e] of bookTime) {
const start = 60 * parseInt(s.slice(0, 2)) + parseInt(s.slice(3));
let end = 60 * parseInt(e.slice(0, 2)) + parseInt(e.slice(3)) + 10;

if (end > 60 * 24 - 1) {
end = 60 * 24 - 1;
}

for (let i = start; i < end; i++) {
time[i] += 1;
}
}

return Math.max(...time);
}
35 changes: 35 additions & 0 deletions Hyeple/231128/pro_92335.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function isPrime(N) {
if (N === 1) {
return false;
}
for (let i = 2; i <= Math.sqrt(N); i++) {
if (N % i === 0) {
return false;
}
}
return true;
}

function convert(n, q) {
let revBase = "";

while (n > 0) {
const [div, mod] = [Math.floor(n / q), n % q];
n = div;
revBase += mod.toString();
}

return revBase.split("").reverse().join("");
}

function solution(n, k) {
let answer = 0;
for (const i of convert(n, k).split("0")) {
if (i !== "") {
if (isPrime(parseInt(i))) {
answer += 1;
}
}
}
return answer;
}

0 comments on commit 0d228d7

Please sign in to comment.