-
Notifications
You must be signed in to change notification settings - Fork 4
[unn04012] 25.01.13 #23
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 our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c942abf
๋ฐฐ์ด ์๋ฅด๊ธฐ, ๊ธฐ์ด
unn04012 0bbc32d
๋ฐฐ์ด ํ์ ์ํค๊ธฐ, ๊ธฐ์ด
unn04012 73a4661
์ ์ผ ์์ ์ ์ ๊ฑฐํ๊ธฐ, ์ค๊ธ
unn04012 a3b4f62
๋๋์ด ๋จ์ด์ง๋ ์ซ์ ๋ฐฐ์ด, ์ค๊ธ
unn04012 2360efc
ํ๋ ฌ์ ๊ณฑ์
, ์ฌํ
unn04012 3e0c123
๋ฌธ์์ด ๋ค์ง๊ธฐ(๊ธฐ์ด)
unn04012 02ec602
์ปจํธ๋กค_์ ํธ(๊ธฐ์ด)
unn04012 8803f24
์์ด๊ฐ_์ซ์ด์(๊ธฐ์ด)
unn04012 c34eecd
๋ฌธ์์ด_๊ณ์ฐํ๊ธฐ(๊ธฐ์ด)
unn04012 1f6fd0b
ํฌ๋ ์ธ ์ธํ๋ฝ๊ธฐ ๊ฒ์(์ค๊ธ)
unn04012 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| function solution(arr, divisor) { | ||
| const answer = []; | ||
|
|
||
| for (const e of arr) { | ||
| if (e % divisor === 0) answer.push(e); | ||
| } | ||
| if (answer.length === 0) answer.push(-1); | ||
|
|
||
| return answer.sort((a, b) => a - b); | ||
| } | ||
|
|
||
| console.log(solution([5, 9, 7, 10], 5)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| function solution(arr1, arr2) { | ||
| const n = arr1.length; | ||
| const m = arr2[0].length; | ||
|
|
||
| const answer = Array.from({ length: n }, () => Array(m).fill(0)); | ||
|
|
||
| for (let i = 0; i < n; i++) { | ||
| for (let j = 0; j < m; j++) { | ||
| const result = arr1[i].reduce((acc, cur, idx) => acc + cur * arr2[idx][j], 0); | ||
|
|
||
| answer[i][j] = result; | ||
| } | ||
| } | ||
|
|
||
| return answer; | ||
| } | ||
|
|
||
| console.log( | ||
| solution( | ||
| [ | ||
| [2, 3, 2], | ||
| [4, 2, 4], | ||
| [3, 1, 4], | ||
| ], | ||
| [ | ||
| [5, 4, 3], | ||
| [2, 4, 1], | ||
| [3, 1, 1], | ||
| ] | ||
| ) | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| function solution(numbers, direction) { | ||
| const answer = []; | ||
|
|
||
| if (direction === 'right') { | ||
| for (let i = 0; i < numbers.length - 1; i++) { | ||
| answer[i + 1] = numbers[i]; | ||
| } | ||
| answer[0] = numbers[numbers.length - 1]; | ||
| } else { | ||
| for (let i = numbers.length - 1; i >= 1; i--) { | ||
| answer[i - 1] = numbers[i]; | ||
| } | ||
| answer[numbers.length - 1] = numbers[0]; | ||
| } | ||
|
|
||
| return answer; | ||
| } | ||
|
|
||
| console.log(solution([4, 455, 6, 4, -1, 45, 6], 'left')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| function solution(numbers, num1, num2) { | ||
| const answer = []; | ||
|
|
||
| for (let i = num1; i <= num2; i++) answer.push(numbers[i]); | ||
|
|
||
| return answer; | ||
| } | ||
|
|
||
| console.log(solution([1, 2, 3, 4, 5], 1, 3)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| function solution(arr) { | ||
| const answer = []; | ||
| const minNum = Math.min(...arr); | ||
|
|
||
| for (const e of arr) { | ||
| if (e === minNum) continue; | ||
| answer.push(e); | ||
| } | ||
| return answer.length ? answer : [-1]; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| function solution(board, moves) { | ||
| let answer = 0; | ||
| const stack = []; | ||
| const width = board.length; | ||
|
|
||
| const pullCrane = (order) => { | ||
| const w = order - 1; | ||
| let h = 0; | ||
|
|
||
| while (width > h) { | ||
| const doll = board[h][w]; | ||
| if (doll !== 0) { | ||
| if (stack[stack.length - 1] === doll) { | ||
| stack.pop(); | ||
| answer += 2; | ||
| } else { | ||
| stack.push(board[h][w]); | ||
| } | ||
|
|
||
| board[h][w] = 0; | ||
| break; | ||
| } | ||
| h++; | ||
| } | ||
| }; | ||
|
|
||
| moves.forEach((e) => pullCrane(e)); | ||
|
|
||
| return answer; | ||
| } | ||
|
|
||
| console.log( | ||
| solution( | ||
| [ | ||
| [0, 0, 0, 0, 0], | ||
| [0, 0, 1, 0, 3], | ||
| [0, 2, 5, 0, 1], | ||
| [4, 2, 4, 4, 2], | ||
| [3, 5, 1, 3, 1], | ||
| ], | ||
| [1, 5, 3, 5, 1, 2, 1, 4] | ||
| ) | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| function solution(numbers) { | ||
| let answer = numbers; | ||
| const englishObj = { | ||
| zero: 0, | ||
| one: 1, | ||
| two: 2, | ||
| three: 3, | ||
| four: 4, | ||
| five: 5, | ||
| six: 6, | ||
| seven: 7, | ||
| eight: 8, | ||
| nine: 9, | ||
| }; | ||
|
|
||
| for (const [key, value] of Object.entries(englishObj)) { | ||
| if (numbers.includes(key)) { | ||
| answer = answer.replaceAll(key, value); | ||
| } | ||
| } | ||
|
|
||
| return Number(answer); | ||
| } | ||
|
|
||
| console.log(solution('onefourzerosixseven')); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| function solution(s) { | ||
| const stack = []; | ||
| let answer = 0; | ||
|
|
||
| s.split(' ').forEach((e) => { | ||
| // ์ซ์๊ฐ ์๋๋ฉด | ||
| if (Number.isNaN(Number(e))) { | ||
| answer -= stack.pop(); | ||
| } else { | ||
| const num = Number(e); | ||
| answer += num; | ||
| stack.push(num); | ||
| } | ||
| }); | ||
|
|
||
| return answer; | ||
| } | ||
|
|
||
| console.log(solution('10 Z 20 Z')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| function solution(my_string) { | ||
| let answer = 0; | ||
|
|
||
| const expression = my_string.split(' ').reverse(); | ||
|
|
||
| while (expression.length) { | ||
| const element = expression.pop(); | ||
|
|
||
| if (element === '+') { | ||
| answer += Number(expression.pop()); | ||
| expression.push(answer); | ||
| } else if (element === '-') { | ||
| answer -= Number(expression.pop()); | ||
| expression.push(answer); | ||
| } else { | ||
| // ์ซ์์ธ ๊ฒฝ์ฐ | ||
| answer = Number(element); | ||
| } | ||
| } | ||
|
|
||
| return answer; | ||
| } | ||
|
|
||
| console.log(solution('3 + 4 - 2')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| function solution(my_string) { | ||
| return my_string.split('').reverse().join(''); | ||
| } | ||
|
|
||
| console.log(solution('jaron')); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ค ํด์ฌ๋ก๋ ํ ์ ์๊ตฐ์.. ๋ฐฐ์๊ฐ๋๋ค!