✅ Finding all possibilities of N length in an array
Hey so I have the Following code which basically iterate on all my tiles and create arrays of 3 of them, iterating on all possibilities
I'm trying to make this code generic so instead of arrays of 3, it can be array of N, but I'm not sure how to approche that
Could someone please help me with that?
12 Replies
What is
matching
in this case? You're checking its length, but then access Deck
. Seems like a mistake?Hmm, yeah it's some old code and I think it was indeed a mistake
I'll edit the post but it's supposed to be the same list yeah my bad
Something like that
I'll need to put that on a paper so my two braincells can understand what is happening but I'll investigate that, thanks a lot
There's an easier way actually
Oh, what is it if I may ask?
This should probably also work?
Or if you don't like the tospan
Mh nah the alternative would suck
Ah wait you need to slice
matching
as wellSo from what I understand is final size is 3 and I have
[1, 2, 3, 4, 5], 0 given
It would give
0, 1, 2, 3
0, 2, 3, 4
0, 3, 4, 5
Right?
wait no let me edit
Ah, was that the goal? I assumed
1, 2, 3
, 4, 5, 6
etcMaybe im wrong im just trying to understand your code
my goal was this
To get all different possibilities
So with
But with 4 values instead of 3 it increase a lot the amount of combinaisons
Shouldn't be more complicated than this then
Oh that's simpler than expected
I'll try with that, thanks :)