Skip to content

[19주차] 풀이추가 #83

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 28 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a18681d
solution: level 2 / 하노이 탑 풀이 추가
codeisneverodd Jul 19, 2022
32adc56
solution: 모음사전
codeisneverodd Jul 20, 2022
876d450
solution 체육복
chaerin-dev Jul 19, 2022
8127da5
solution 모의고사
chaerin-dev Jul 19, 2022
8061345
solution 위장
chaerin-dev Jul 19, 2022
4fb5408
solution 튜플
chaerin-dev Jul 19, 2022
1cbfe92
브랜치 흐름 정리 (#71)
codeisneverodd Jul 20, 2022
2df8161
Merge branch 'main' into week
codeisneverodd Jul 20, 2022
4440efc
fix: base url 핫픽스 (#74)
codeisneverodd Jul 22, 2022
6f946ef
Merge branch 'main' into week
codeisneverodd Jul 22, 2022
031c52d
[손재영] level2 배달 풀이 및 주석
pereng11 Jul 23, 2022
d2b9fd3
solution 구명보트
iHoHyeon Jul 24, 2022
0cd0d67
Merge branch 'week' into main
codeisneverodd Jul 25, 2022
1ae2b59
Merge pull request #77 from iHoHyeon/main
codeisneverodd Jul 25, 2022
8938fca
fix: 최소힙 클래스 바깥 분리&파일 컨벤션 적용
pereng11 Jul 25, 2022
f16e1fe
Merge branch 'week' into jaeyeong
codeisneverodd Jul 25, 2022
35c30f2
solution level2 - 숫자 블록 (#79)
iHoHyeon Aug 3, 2022
d503fd8
solution: level2 - 피로도 문제 풀이
pereng11 Aug 8, 2022
7d95572
Merge branch 'jaeyeong' of https://github.com/pereng11/programmers-co…
pereng11 Aug 8, 2022
6c56cbf
Merge branch 'week-19' into jaeyeong
codeisneverodd Aug 12, 2022
597555a
refactor: level2 - 피로도(가독성 개선)
pereng11 Aug 12, 2022
89ff531
Merge branch 'jaeyeong' of https://github.com/pereng11/programmers-co…
pereng11 Aug 12, 2022
41adac3
Merge pull request #80 from pereng11/jaeyeong
codeisneverodd Aug 17, 2022
3a7effc
feat: PR 템플릿 위치 변경
codeisneverodd Aug 17, 2022
31d2036
feat: husky 및 pre-commit hook 설정, prettierignore 추가
codeisneverodd Aug 17, 2022
fadb330
Merge pull request #82 from codeisneverodd/week-19-codeisneverodd
codeisneverodd Aug 17, 2022
14e4ee2
fix: 잘못 업로드된 해설 삭제
codeisneverodd Aug 17, 2022
0c59931
Merge branch 'main' into week-19
codeisneverodd Aug 17, 2022
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
2 changes: 0 additions & 2 deletions .github/workflows/update-README.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ on:
push:
branches:
- main
- manage
pull_request:
branches:
- main
- manage
jobs:
build:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

README.md
# Created by https://www.toptal.com/developers/gitignore/api/macos,webstorm
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,webstorm

Expand Down
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/node_modules
.gitignore
.prettierrc.json
README.md
/.github
/.husky
234 changes: 0 additions & 234 deletions README.md

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions level-2/숫자-블록.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//https://github.com/codeisneverodd/programmers-coding-test
//완벽한 정답이 아닙니다.
//정답 1 - iHoHyeon
function solution(begin, end) {
return new Array(end - begin + 1).fill(null).map((v, idx) => calc(begin + idx));
// begin ~ end 각 위치에 대해서 calc 함수의 return 값으로 채운다.
}

const calc = (number) => {
if (number === 1) return 0;
// 1번째 위치는 무조건 0블록이 위치

for (let i = 2; i <= Math.sqrt(number); i++) {
if (number % i === 0 && number / i <= 10_000_000) return number / i;
// 10_000_000번 블록까지만 놓았으므로 숫자를 초과하는 경우는 제외
}

return 1;
};

/*
1번 블록부터 10_000_000번 블록까지 전부 규칙에 따라서 놓는 경우는
시간 / 공간 복잡도가 급상승

-> 따라서 각 위치에 어떤 숫자의 블록이 놓일지를 계산해주자

-> n번째 위치에는 1, n을 제외한 n의 가장 큰 약수의 블록이 놓이게 된다.

-> 가장 큰 약수는 n / (n의 가장 작은 약수)임을 이용해서 계산해주면 된다.

+ 가장 큰 약수가 1인 경우는 소수인 경우이고 숫자 1 블록이 놓인다.
*/
28 changes: 28 additions & 0 deletions level-2/피로도.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//https://github.com/codeisneverodd/programmers-coding-test
//완벽한 정답이 아닙니다.
//정답 1 - pereng11
//완전 탐색, greedy O(N^2)
function solution(currentFatigue, dungeons) {
return getMaxCount(currentFatigue, 0, dungeons);
}

function getMaxCount(currentFatigue, visitedCount, dungeons) {
const possibleDungeons = dungeons.filter(([minNeededFatigue, _]) => minNeededFatigue <= currentFatigue);
if (possibleDungeons.length === 0) return visitedCount;

const maxCount = possibleDungeons.reduce((prevCount, curr, currentIndex) => {
const [_, usedFatigue] = curr;
const nextDungeons = possibleDungeons.filter((_, index) => index !== currentIndex);
const currentCount = getMaxCount(
currentFatigue - usedFatigue,
visitedCount + 1,
nextDungeons
);
return Math.max(currentCount, prevCount);
}, 0);

return maxCount;
}



Loading