Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[ryan-dia] level 2 문제 풀이 추가#121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Ryan-Dia wants to merge2 commits intocodeisneverodd:main
base:main
Choose a base branch
Loading
fromRyan-Dia:sub
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletionlevel-2/k진수에서-소수-개수-구하기&92335&.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,4 +20,35 @@ function solution(n, k) {
// .split('0') // 0을 기준으로 나눕니다.
// .filter((number) => isPrime(+number)).length // 소수가 아닌 요소를 걸러낸 후에 개수를 셉니다.
return (n).toString(k).split('0').filter((number) => isPrime(+number)).length;
}
}


// 정답 2 - ryna-dia

function solution(n, k) {
const numbers = n;
const antilogarithm = k;
const NumbersChangedAntilogarithm = numbers.toString(antilogarithm);
const result = selectPrimeNotIncludeZero(NumbersChangedAntilogarithm);

return result.length;
}

function selectPrimeNotIncludeZero(numbers, numbersWithoutZero = '') {
return [...numbers].reduce((acc, cur, index, arr) => {
if (cur !== '0') numbersWithoutZero += cur;
if (cur === '0' || index === arr.length - 1) {
if (isPrime(Number(numbersWithoutZero))) acc.push(numbersWithoutZero);
numbersWithoutZero = '';
}
return acc;
}, []);
}

function isPrime(num) {
if (!num || num === 1) return false;
for (let i = 2; i <= Math.sqrt(num); i++) {
if (!(num % i)) return false;
}
return true;
}
21 changes: 21 additions & 0 deletionslevel-2/프린터&42587&.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -134,3 +134,24 @@ class Queue {
return this.rear - this.front
}
}

// 정답 6 ryan-dia

function solution(priorities, location, result = 0) {
const queue = priorities.map((p, i) => ({ priority: p, index: i }));

while (queue.length > 0) {
const current = queue.shift();
const higherPriority = queue.some((d) => d.priority > current.priority);

if (higherPriority) {
queue.push(current);
continue;
}
result += 1;
if (current.index === location) {
return result;
}
}
}


[8]ページ先頭

©2009-2025 Movatter.jp