Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
58dae09
remove smallest number / ไปฅ๎‡๏ฟฝ
JustDevRae Jan 2, 2025
d1ddf64
divisible numbers array / ไปฅ๎‡๏ฟฝ
JustDevRae Jan 2, 2025
8d7fe56
duplicate number count / ๆนฒ๊ณ—๏ฟฝ
JustDevRae Jan 2, 2025
d7f63b0
matrix addition / ไปฅ๎‡๏ฟฝ
JustDevRae Jan 2, 2025
36b4d80
array element length / ๆนฒ๊ณ—๏ฟฝ
JustDevRae Jan 2, 2025
bab0b85
rotate array / ๆนฒ๊ณ—๏ฟฝ
JustDevRae Jan 2, 2025
c8b3d17
slice array / ๆนฒ๊ณ—๏ฟฝ
JustDevRae Jan 2, 2025
45ce6e5
array algorithm md file
JustDevRae Jan 2, 2025
38a1f64
reverse string / ๊ธฐ์ดˆ
JustDevRae Jan 9, 2025
8219e21
control Z / ๊ธฐ์ดˆ
JustDevRae Jan 9, 2025
3654602
dart game / ์ค‘๊ธ‰
JustDevRae Jan 9, 2025
1e2f2b0
valid parentheses / ์ค‘๊ธ‰
JustDevRae Jan 9, 2025
a4143c9
crane claw game / ์ค‘๊ธ‰
JustDevRae Jan 9, 2025
ea29442
pull origin JustDevRae branch
JustDevRae Jan 14, 2025
77e2e30
pair count / ๆนฒ๊ณ—๏ฟฝ
JustDevRae Jan 15, 2025
c0967b7
find point position / ๆนฒ๊ณ—๏ฟฝ
JustDevRae Jan 15, 2025
d2dc9af
login success / ๆนฒ๊ณ—๏ฟฝ
JustDevRae Jan 15, 2025
5928dbd
card bundle / ไปฅ๎‡๏ฟฝ
JustDevRae Jan 17, 2025
0d2f982
make hamburger / ไปฅ๎‡๏ฟฝ
JustDevRae Jan 17, 2025
df8ffd4
process / ๏ฟฝั‹๏ฟฝ
JustDevRae Jan 17, 2025
281c961
morse code / ๆนฒ๊ณ—๏ฟฝ
JustDevRae Jan 25, 2025
51c45ac
make B with A / ๆนฒ๊ณ—๏ฟฝ
JustDevRae Jan 25, 2025
40ee840
setting order care / ๆนฒ๊ณ—๏ฟฝ
JustDevRae Jan 25, 2025
f9ab318
not finish runner / ไปฅ๎‡๏ฟฝ
JustDevRae Jan 25, 2025
8f38987
rank order / ๆนฒ๊ณ—๏ฟฝ
JustDevRae Jan 25, 2025
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
21 changes: 21 additions & 0 deletions JustDevRae/Hash/make_B_with_A.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function solution(before, after) {
var answer = 0;
const beforeCount = {};
const afterCount = {};

for (const char of before) {
beforeCount[char] = (beforeCount[char] || 0) + 1;
}

for (const char of after) {
afterCount[char] = (afterCount[char] || 0) + 1;
}

for (const key in beforeCount) {
if (beforeCount[key] !== afterCount[key]) {
return (answer = 0);
}
}

return (answer = 1);
}
37 changes: 37 additions & 0 deletions JustDevRae/Hash/morse_code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function solution(letter) {
var answer = "";
const morse = {
".-": "a",
"-...": "b",
"-.-.": "c",
"-..": "d",
".": "e",
"..-.": "f",
"--.": "g",
"....": "h",
"..": "i",
".---": "j",
"-.-": "k",
".-..": "l",
"--": "m",
"-.": "n",
"---": "o",
".--.": "p",
"--.-": "q",
".-.": "r",
"...": "s",
"-": "t",
"..-": "u",
"...-": "v",
".--": "w",
"-..-": "x",
"-.--": "y",
"--..": "z",
};
const str = letter.split(" ");

for (const s of str) {
answer += morse[s];
}
return answer;
}
21 changes: 21 additions & 0 deletions JustDevRae/Hash/not_finish_runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function solution(participant, completion) {
const obj = {};

for (const p of participant) {
if (obj[p]) {
obj[p] += 1;
} else {
obj[p] = 1;
}
}

for (const c of completion) {
obj[c] -= 1;
}

for (const key in obj) {
if (obj[key] > 0) {
return key;
}
}
}
6 changes: 6 additions & 0 deletions JustDevRae/Hash/rank_order.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function solution(score) {
const averages = score.map(([english, math]) => (english + math) / 2);
const sortedAverages = [...averages].sort((a, b) => b - a);

return averages.map((avg) => sortedAverages.indexOf(avg) + 1);
}
10 changes: 10 additions & 0 deletions JustDevRae/Hash/setting_order_care.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function solution(emergency) {
const sorted = [...emergency].sort((a, b) => b - a);
const rankMap = new Map();

sorted.forEach((value, index) => {
rankMap.set(value, index + 1);
});

return emergency.map((value) => rankMap.get(value));
}
15 changes: 15 additions & 0 deletions JustDevRae/Queue/card_bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function solution(cards1, cards2, goal) {
var answer = "";
for (let word of goal) {
if (word == cards1[0]) {
cards1.shift();
} else if (word == cards2[0]) {
cards2.shift();
} else {
answer = "No";
break;
}
}

return (answer = "Yes");
}
10 changes: 10 additions & 0 deletions JustDevRae/Queue/find_point_position.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function solution(dot) {
var answer = 0;

if (dot[0] > 0 && dot[1] > 0) answer = 1;
if (dot[0] < 0 && dot[1] > 0) answer = 2;
if (dot[0] < 0 && dot[1] < 0) answer = 3;
if (dot[0] > 0 && dot[1] < 0) answer = 4;

return answer;
}
16 changes: 16 additions & 0 deletions JustDevRae/Queue/login_success.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function solution(id_pw, db) {
var answer = "";
for (let i = 0; i < db.length; i++) {
if (id_pw[0] === db[i][0]) {
if (id_pw[1] === db[i][1]) {
answer = "login";
break;
}
answer = "wrong pw";
break;
} else {
answer = "fail";
}
}
return answer;
}
20 changes: 20 additions & 0 deletions JustDevRae/Queue/make_hamburger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function solution(ingredient) {
const burger = [];
let answer = 0;
for (let i of ingredient) {
burger.push(i);

if (
burger.length >= 4 &&
burger[burger.length - 4] === 1 &&
burger[burger.length - 3] === 2 &&
burger[burger.length - 2] === 3 &&
burger[burger.length - 1] === 1
) {
burger.splice(burger.length - 4, 4);
answer++;
}
}

return answer;
}
13 changes: 13 additions & 0 deletions JustDevRae/Queue/pair_count.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function solution(n) {
var answer = 0;

// 1๋ถ€ํ„ฐ n๊นŒ์ง€ ์ˆซ์ž๋ฅผ ํ™•์ธ
for (let i = 1; i <= n; i++) {
// i๊ฐ€ n์˜ ์•ฝ์ˆ˜์ธ์ง€ ํ™•์ธ
if (n % i === 0) {
// i๊ฐ€ n์˜ ์•ฝ์ˆ˜์ธ์ง€ ํ™•์ธ
answer++;
}
}
return answer;
}
20 changes: 20 additions & 0 deletions JustDevRae/Queue/process.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function solution(priorities, location) {
var answer = 0;
const queue = priorities.map((priority, index) => ({ priority, index }));

while (queue.length > 0) {
const current = queue.shift();

const highPriority = queue.some((item) => item.priority > current.priority);

if (highPriority) {
queue.push(current);
} else {
answer++;

if (current.index === location) {
return answer;
}
}
}
}
15 changes: 15 additions & 0 deletions JustDevRae/Stack/control_Z.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function solution(s) {
var answer = 0;
let Z = 0;
const controlArray = s.split(" ");
for (let i = 0; i < controlArray.length; i++) {
if (controlArray[i] == "Z") {
answer -= Z;
continue;
}
answer += Number(controlArray[i]);
Z = Number(controlArray[i]);
}

return answer;
}
23 changes: 23 additions & 0 deletions JustDevRae/Stack/crane_claw_game.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function solution(board, moves) {
let answer = 0;
const stack = [];

for (let move of moves) {
for (let i = 0; i < board.length; i++) {
if (board[i][move - 1] !== 0) {
let doll = board[i][move - 1];
board[i][move - 1] = 0;

if (stack.length > 0 && stack[stack.length - 1] === doll) {
stack.pop();
answer += 2;
} else {
stack.push(doll);
}
break;
}
}
}

return answer;
}
41 changes: 41 additions & 0 deletions JustDevRae/Stack/dart_game.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
function solution(dartResult) {
var answer = 0;
const dartResultArray = dartResult.match(/\d+|[SDT]|\#|\*/g);
const stack = [];
let value;

for (str of dartResultArray) {
if (str === "S") {
value = stack.pop();
stack.push(value);
} else if (str === "D") {
value = stack.pop();
stack.push(value * value);
} else if (str === "T") {
value = stack.pop();
stack.push(value * value * value);
} else if (str === "*") {
let firtPopValue = stack.pop();
firtPopValue *= 2;
let secondPopValue = stack.pop();
if (secondPopValue === undefined) {
stack.push(firtPopValue);
} else {
secondPopValue *= 2;
stack.push(secondPopValue);
stack.push(firtPopValue);
}
} else if (str === "#") {
value = stack.pop();
stack.push(value * -1);
} else {
stack.push(Number(str));
}
}

for (element of stack) {
answer += element;
}

return answer;
}
10 changes: 10 additions & 0 deletions JustDevRae/Stack/reverse_string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function solution(my_string) {
var answer = "";
const string = [...my_string];

for (let i = 0; i < my_string.length; i++) {
answer += string.pop();
}

return answer;
}
16 changes: 16 additions & 0 deletions JustDevRae/Stack/valid_parentheses.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function solution(s) {
const stack = [];
for (const c of s) {
if (c === "(") {
stack.push(c);
} else if (c === ")") {
if (stack.length === 0) {
continue;
} else {
stack.pop();
}
}
}

return stack.length === 0;
}
Loading