일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- 문자열
- 알고리즘
- 가천대
- 타입스크립트
- javascript
- 자바스크립트
- HTTP 완벽 가이드
- type challenge
- typescript
- dfs
- 레벨 1
- HTTP
- socket
- 크롤링
- 타입 챌린지
- BFS
- 소켓
- 백준
- 쉬운 문제
- Algorithm
- ip
- 수학
- dp
- Crawling
- Nestjs
- Node.js
- TCP
- 프로그래머스
- 프로그래머스 레벨 2
- 그래프
- Today
- Total
목록javascript (104)
kakasoo
// // 프로그래머스 레벨 1 2019 KAKAO BLIND RECRUITMENT > [1차]비밀지도를 풀었습니다. const numPad = (n, number) => { while (String(number).length numPad(n, el.toString(2))); arr2 = arr2.map((el) => numPad(n, el.toString(2))); for (let i = 0; i < arr1.length; i++) { let row = ""; for (let j ..
// 프로그래머스 레벨 1 2019 KAKAO BLIND RECRUITMENT > 실패율을 풀었습니다. function solution(N, stages) { let answer = []; let allPlayer = stages.length; for (let i = 1; i el === i).length; let fail; if (stageNum === 0) fail = 0; else { fail = stageNum / allPlayer; } allPlayer -= stageNum; answer.push({ idx: i, ratio: fail }); } return answer.sort((o1, o2) => -o1.ratio + o2.ratio).map((el) => el.idx); }
// 프로그래머스 레벨1 직사각형 별찍기를 풀었습니다. process.stdin.setEncoding("utf8"); process.stdin.on("data", (data) => { const n = data.split(" "); const a = Number(n[0]), b = Number(n[1]); for (let i = 0; i < b; i++) { for (let j = 0; j < a; j++) { process.stdout.write("*"); } console.log(); } }); 다 더해주기만 하면 되는 간단한 문제.
// 프로그래머스 레벨1 x만큼 간격이 있는 n개의 숫자를 풀었습니다. function solution(x, n) { let arr = [x]; let temp = x; for (let i = 0; i < n - 1; i++) { temp += x; arr.push(temp); } return arr; } 다 더해주기만 하면 되는 간단한 문제.
// 프로그래머스 레벨1 행렬의 덧셈을 풀었습니다. function solution(arr1, arr2) { return arr1.map((el, i) => el.map((n, j) => (n += arr2[i][j]))); } 다 더해주기만 하면 되는 간단한 문제.
// 프로그래머스 레벨1 핸드폰 번호 가리기를 풀었습니다. function solution(phone_number) { let a, b, c, d, e; let arr = ([a, b, c, d, ...e] = phone_number.split("").reverse()); return [e.map((el) => "*").join(""), d, c, b, a].join(""); } 구조분해할당과 나머지 연산자를 이용하면 쉽게 가능해진다.
// 프로그래머스 레벨1 하샤드 수를 풀었습니다. function solution(x) { return ( x % String(x) .split("") .map((el) => Number(el)) .reduce((acc, cur) => acc + cur) === 0 ); } 자기 자신의 각 자릿수의 합으로 나누어 떨어지는 수.
// 프로그래머스 레벨1 평균구하기를 풀었습니다. function solution(arr) { return arr.reduce((acc, cur) => acc + cur) / arr.length; }
// 프로그래머스 레벨1 최대공약수와 최소공배수를 풀었습니다. function solution(n, m) { if (n > m) [n, m] = [m, n]; const arr = []; for (let i = 2; i acc * cur); const max = min === 1 ? n * m : min * n * m; return [min, max]; } 이제는 gcd를 구하지, 저렇게 구하지 않는다. 재귀적 방법이 더 쉽기 때문이다.
// 프로그래머스 레벨1 짝수와 홀수를 풀었습니다. function solution(num) { if (num % 2 === 0) return "Even"; return "Odd"; } const solution = (num) => ["Even", "Odd"][num]; 이렇게도 가능하긴 하다. 작년 9월에 풀어서 코드가 C++ 같다.
// 프로그래머스 level1 제일 작은 수 제거하기를 풀었습니다. function solution(arr) { let min = 9875654321; if (arr.length === 1) return [-1]; arr.map((el, i) => { if (el < min) min = el; return el; }); arr.splice(arr.indexOf(min), 1); return arr; }