Skip to content

Commit

Permalink
#8 22.11.16 > 수들의 조합
Browse files Browse the repository at this point in the history
  • Loading branch information
beurmuz committed Nov 16, 2022
1 parent fd74a9f commit 475b256
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 17 deletions.
24 changes: 24 additions & 0 deletions src/inf/recursive,dfs/15_rere.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use strict";

function solution(n, k, arr, m) {
let answer = 0;
let combiArr = Array.from({ length: k }, () => 0);

function dfs(L, s, sum) {
if (L === k) {
if (sum % m === 0) {
console.log(sum, combiArr);
answer++;
}
} else {
for (let i = s; i < n; i++) {
combiArr[L] = arr[i];
dfs(L + 1, i + 1, sum + arr[i]);
}
}
}
dfs(0, 0, 0);
return answer;
}
let arr = [2, 4, 5, 8, 12];
console.log(solution(5, 3, arr, 6));
34 changes: 17 additions & 17 deletions src/inf/recursive,dfs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
# List

| 번호 | 정답여부 | 재응시 |
| :--: | :------: | :------------------: |
| 1 || 22.11.01 |
| 2 | O | 22.11.09 |
| 3 || 22.11.09 |
| 4 | X | 22.11.11😥 |
| 5 | X | 22.11.11😥 |
| 6 || 22.11.11😥 |
| 7 || 22.11.11 |
| 8 | X | 22.11.15😥 |
| 9 || 22.11.15😥 |
| 10 || 22.11.15😥 |
| 11 | O | 22.11.15 |
| 12 | X | 22.11.16😥 |
| 13 | X | 22.11.16😥 |
| 14 | X | 22.11.16😥 |
| 15 | X | O 잊기전에 다시풀기! |
| 번호 | 정답여부 | 재응시 |
| :--: | :------: | :--------: |
| 1 || 22.11.01 |
| 2 | O | 22.11.09 |
| 3 || 22.11.09 |
| 4 | X | 22.11.11😥 |
| 5 | X | 22.11.11😥 |
| 6 || 22.11.11😥 |
| 7 || 22.11.11 |
| 8 | X | 22.11.15😥 |
| 9 || 22.11.15😥 |
| 10 || 22.11.15😥 |
| 11 | O | 22.11.15 |
| 12 | X | 22.11.16😥 |
| 13 | X | 22.11.16😥 |
| 14 | X | 22.11.16😥 |
| 15 | X | 22.11.16😥 |

0 comments on commit 475b256

Please sign in to comment.