Skip to content

Commit 10a301f

Browse files
level0 문제 풀이 중간 저장
1 parent 7b21a65 commit 10a301f

File tree

104 files changed

+818
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+818
-4
lines changed
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(num_list, n) {
5+
let result = [];
6+
for (let i = 0; i < num_list.length / n; i++) {
7+
result = [...result, num_list.slice(i * n, i * n + n)];
8+
}
9+
return result;
10+
}

level-0/369게임&120891&.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(order) {
5+
return [...('' + order)].filter(num => num === '3' || num === '6' || num === '9').length;
6+
}

level-0/7의-개수&120912&.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(array) {
5+
return [...array.join('')].filter(a => a === '7').length;
6+
}

level-0/A로-B-만들기&120886&.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(before, after) {
5+
const sort = str => [...str].sort((a, b) => (a < b ? -1 : a !== b ? 1 : 0)).join('');
6+
return sort(before) === sort(after) ? 1 : 0;
7+
}

level-0/OX퀴즈&120907&.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(n) {
5+
//프로그래머스에 제출하여 통과된 함수를 복사 붙여넣기 해주세요!
6+
}

level-0/k의-개수&120887&.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(i, j, k) {
5+
let count = 0;
6+
for (let num = i; num <= j; num++) {
7+
count += [...('' + num)].filter(n => +n === k).length;
8+
}
9+
return count;
10+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(n, numlist) {
5+
return numlist.filter(num => num % n === 0);
6+
}

level-0/가까운-수&120890&.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(array, n) {
5+
const minDiff = Math.min(...array.map(a => Math.abs(a - n)));
6+
return array.sort((a, b) => a - b).find(a => Math.abs(a - n) === minDiff);
7+
}

level-0/가위-바위-보&120839&.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(rsp) {
5+
const win = { 0: 5, 2: 0, 5: 2 };
6+
return [...rsp].map(num => win[num]).join('');
7+
}
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(array) {
5+
const max = Math.max(...array);
6+
return [max, array.indexOf(max)];
7+
}

level-0/각도기&120829&.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(angle) {
5+
if (angle === 180) return 4;
6+
if (angle > 90) return 3;
7+
if (angle === 90) return 2;
8+
return 1;
9+
}

level-0/개미-군단&120837&.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(hp) {
5+
const first = Math.floor(hp / 5);
6+
const second = Math.floor((hp - first * 5) / 3);
7+
const third = hp - first * 5 - second * 3;
8+
return first + second + third;
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(n) {
5+
//프로그래머스에 제출하여 통과된 함수를 복사 붙여넣기 해주세요!
6+
}

level-0/공-던지기&120843&.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(numbers, k) {
5+
const goNext = current => (current + 2) % numbers.length;
6+
let current = 0;
7+
for (let i = 0; i < k - 1; i++) current = goNext(current);
8+
return numbers[current];
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(balls, share) {
5+
const [n, m] = [balls, share];
6+
const fact = [BigInt(1), BigInt(1)];
7+
8+
for (let i = 2; i <= n; i++) fact[i] = fact[i - 1] * BigInt(i);
9+
10+
return Number(fact[n] / (fact[n - m] * fact[m]));
11+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(num1, num2) {
5+
return num1 % num2;
6+
}

level-0/나이-출력&120820&.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(age) {
5+
return 2022 - age + 1;
6+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(common) {
5+
const isAP = arr => arr[2] - arr[1] === arr[1] - arr[0];
6+
return isAP(common)
7+
? common[common.length - 1] + common[1] - common[0]
8+
: common[common.length - 1] * (common[1] / common[0]);
9+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(n) {
5+
//프로그래머스에 제출하여 통과된 함수를 복사 붙여넣기 해주세요!
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(my_string) {
5+
return [...my_string].map(char => (char === char.toUpperCase() ? char.toLowerCase() : char.toUpperCase())).join('');
6+
}

level-0/두-수의-곱&120804&.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(num1, num2) {
5+
return num1 * num2;
6+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(num1, num2) {
5+
return Math.floor((num1 / num2) * 1000);
6+
}

level-0/두-수의-차&120803&.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(num1, num2) {
5+
return num1 - num2;
6+
}

level-0/두-수의-합&120802&.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(num1, num2) {
5+
return num1 + num2
6+
}

level-0/등수-매기기&120882&.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(n) {
5+
//프로그래머스에 제출하여 통과된 함수를 복사 붙여넣기 해주세요!
6+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(n) {
5+
//프로그래머스에 제출하여 통과된 함수를 복사 붙여넣기 해주세요!
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(array, height) {
5+
return array.filter(a => a > height).length;
6+
}

level-0/모스부호-(1)&120838&.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(letter) {
5+
const morse = {
6+
'.-':'a','-...':'b','-.-.':'c','-..':'d','.':'e','..-.':'f',
7+
'--.':'g','....':'h','..':'i','.---':'j','-.-':'k','.-..':'l',
8+
'--':'m','-.':'n','---':'o','.--.':'p','--.-':'q','.-.':'r',
9+
'...':'s','-':'t','..-':'u','...-':'v','.--':'w','-..-':'x',
10+
'-.--':'y','--..':'z'
11+
}
12+
return letter
13+
.split(' ')
14+
.map(l => morse[l])
15+
.join('');
16+
}

level-0/모음-제거&120849&.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(my_string) {
5+
return my_string.replace(/[aeiou]/g, '');
6+
}

level-0/몫-구하기&120805&.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(num1, num2) {
5+
return Math.floor(num1 / num2);
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(my_string, n) {
5+
return [...my_string].map(char => char.repeat(n)).join('');
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(n) {
5+
//프로그래머스에 제출하여 통과된 함수를 복사 붙여넣기 해주세요!
6+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(my_string) {
5+
return [...my_string].reverse().join('');
6+
}

level-0/문자열-밀기&120921&.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(A, B) {
5+
const pushRight = str => [str[str.length - 1], ...str.slice(0, str.length - 1)].join('');
6+
for (let i = 0; i <= A.length; i++) {
7+
if (A === B) return i;
8+
A = pushRight(A);
9+
}
10+
11+
return -1;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(my_string) {
5+
return my_string
6+
.match(/[0-9]/g)
7+
.map(str => +str)
8+
.sort((a, b) => a - b);
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(my_string) {
5+
return [...my_string]
6+
.map(char => char.toLowerCase())
7+
.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
8+
.join('');
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(str1, str2) {
5+
return str1.includes(str2) ? 1 : 2;
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(numbers) {
5+
return numbers.map(n => n * 2);
6+
}

level-0/배열-뒤집기&120821&.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(num_list) {
5+
return num_list.reverse();
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(strlist) {
5+
return strlist.map(s => s.length);
6+
}

level-0/배열-자르기&120833&.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(numbers, num1, num2) {
5+
return numbers.slice(num1, num2 + 1);
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(numbers, direction) {
5+
return direction === 'right'
6+
? [numbers[numbers.length - 1], ...numbers.slice(0, numbers.length - 1)]
7+
: [...numbers.slice(1), numbers[0]];
8+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(s1, s2) {
5+
return s1.filter(s => s2.includes(s)).length;
6+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(numbers) {
5+
return numbers.reduce((a, c) => a + c, 0) / numbers.length;
6+
}

level-0/분수의-덧셈&120808&.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(n) {
5+
//프로그래머스에 제출하여 통과된 함수를 복사 붙여넣기 해주세요!
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(sides) {
5+
const max = Math.max(...sides);
6+
return max < sides.reduce((a, c) => a + c, 0) - max ? 1 : 2;
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(n) {
5+
//프로그래머스에 제출하여 통과된 함수를 복사 붙여넣기 해주세요!
6+
}

level-0/세균-증식&120910&.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(n, t) {
5+
return n * 2 ** t;
6+
}

0 commit comments

Comments
 (0)