Share your repls and programming experiences

← Back to all posts

# WEEKLY 7

Hello everyone! I did it! I thought about the challenge all night yesterday (even while dreaming) and so here's the solution!

Enjoy! The golfed version is in `yeet.js`. As always, I have added colors to the output!

## Walkthrough

I made a log of the occurrences of each number, and then removed the ones that had only `1` occurrence. The rest were then made into an array using a magical `Array.fill()` technique and then `Array.concat`ed together.
update
I made a log of the occurrences of each number, and then removed the ones that had only `1` occurrence. The rest were then made into an array using a magical `Array.fill()` technique and then `Array.concat`ed together. After that, I found all the subsets of that array and then removed the ones that didn't fit the requirements. The process is actually quite fast in my opinion!

## Have a great day!

Yeet

hotnewtop
Warhawk947 (552)

even works for string im impressed

DynamicSquid (4630)

@Warhawk947 hey! that's my thing changing people code for funny results lol :)

AmazingMech2418 (1043)

The only thing now is that there are duplicate subsets. For example, if you put in `1,1,1,1`, it shows `{1,1}` 6 times.

Coder100 (16983)

ah yes thanks for reporting i will now make it remove duplicates @AmazingMech2418

DynamicSquid (4630)

Oh wait, but seriously, I don't understand the question:

User input : [2, 4, 1, 2, 1, 7]
Here, one of the subsets in which the members appear an even number of times is [2, 1, 2, 1] where 2 and 1 both appear twice.
You need to print out all such subsets of the user-entered array.

It says "Here, one of the subsets..." so I think there's multiple answers to that one. For example:

``````// input:
[2, 4, 1, 2, 1, 7]

// all possible subsets (no duplicates):
[2], [4], [1], [7]
[2, 4], [2, 1], [2, 2], [2, 7], [4, 1], [4, 7], [1, 1], [1, 7]
[2, 4, 1], [2, 4, 2], [2, 4, 7]...
and so on...

// all subsets in which each digit can be seen an even number of times:
[2, 2], [1, 1]
[2, 2, 1, 1]``````

So I think that's what the question is referring to? I asked Drone this, but I'm still waiting for a response.

Coder100 (16983)

hello, a subset is like

``{ 1, 2, 3, 4 }``

so, by definition, those subsets are subsets, but he's asking for the subset for all even duplicates, not separate ones

DynamicSquid (4630)

@Coder100 wait, so one subset containing all the even duplicates?

DynamicSquid (4630)

@Coder100 but didn't he say that there could be multiple subsets?

AmazingMech2418 (1043)

Coder100 (16983)

LOL i didn't even read the discussion you guys had but that's some good questions. I think this is correct, unless @TheDrone7 would like to clarify more. @AmazingMech2418

DynamicSquid (4630)

@Coder100 the drone confirmed, I was right

AmazingMech2418 (1043)

@Coder100 Though, I think what it is is that you are supposed to just print all of the subsets which satisfy the condition of all numbers being displayed an even number of times. (and of course, without duplicates, disregarding the order in the set as well (for example, you wouldn't do `[2, 1, 2, 1]` and `[1, 2, 1, 2]`).

DynamicSquid (4630)

@AmazingMech2418

I said: