We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 24ae46a commit 3cabe48Copy full SHA for 3cabe48
src/do02reen24/Review/week15.md
@@ -0,0 +1,7 @@
1
+# :fire: week15
2
+
3
+## :ballot_box_with_check: 프로그래머스 위장(42578)
4
5
+- 조합의 개념을 사용하여 풀 수 있었다.
6
+- 해당 옷을 아예 고르지 않는 경우도 있으므로 각 아이템 길이에 + 1 을 해주었다.
7
+- 모든 옷을 안고르는 경우는 제외해야하므로 정답에서 - 1 을 해주었다.
src/do02reen24/etc/programmers_42578.js
@@ -0,0 +1,19 @@
+const getCombinationNumber = (object) => {
+ let combination = 1;
+ for (const key in object) {
+ const itemLength = object[key].length + 1;
+ combination *= itemLength;
+ }
+ return combination;
8
+};
9
10
+const solution = (clothes) => {
11
+ const closet = {};
12
+ clothes.forEach(([cloth, clothType]) => {
13
+ closet[clothType]
14
+ ? closet[clothType].push(cloth)
15
+ : (closet[clothType] = [cloth]);
16
+ });
17
18
+ return getCombinationNumber(closet) - 1;
19
0 commit comments