Up to 20 digits or 20 different numbers?
If you have 20 different numbers, worst case is that you have 20 pairs of the same number. Then you could just have a chain of subpatches that pass on a list filtered for invalid pairs to the next that does the same and the just have 20 of those. In no way elegant, but it would work if you just have 20 different values in the list.
Up to 20 digits or 20 different numbers?
Sorry for this misunderstanding, I mean 20 différents numbers, (from 0 to 19). So 10 combination, so 10 subpatch. And yes this chain is what I wanted to say when I said :
But I would have love the elegant way :)
(And I will do it 50 times so I can make sure that I can extend this 10 combinations limit in case I need it for my project)
did a plugin. does it do what it should?
combinations.zip (15.7 kB)
that’s it! that’s it! Thanks for sharing.
hmm not sure… as in rogerlettes example the rule seems to a bit different as allready used values suddenly get used again under certain conditions. dont really get the logic here…
Tested against a lot of combinations.
rogerlette would feed it with a number of pairs, where each pair has always two different values. And your plugin returns always the valid pairs, where a valid pair is a pair that does not contain any value contained in other pair, - from first pair to last pair.
Post a patch using your plugin inside rogerlette example or indicate which seed number for randomize would return such a repetition.
I test many stuff, even out of my field of use, and it seems to be just perfect!
I dont know what could be wrong? I dont see what you mean by :
Thanks a lot!!!
It is much nicer and flexible than copy and paste subpatches.
hmm in your example, values allready apeared in previous slices still make it into valid combinations.
see my example picture… 1-8 is a valid combination even the 8 allready apeared in a previous slice. my example would ignore 1-8 in this case.
what are the exact conditions to pass as a valid combination?
just tested… and it works as in your example :D
didnt undestood my own stuff… but now its clear to me…
I was actually looking at your plugin as it is a good example for me to learn how to do one myself.
And no, your code does not put the 8 in the “usedlist” because on the other side of the OR operation “usedlist” contain 9 so the code go to the next slice… Just perfect.
But of course, you quickly found this as mentionned in your last post, and you dont need me to explain this!
edit : looking at the time of the post, it took you less than 10min to test and find it, it took me 30min:)
tonfilm and i were patching breaking our heads around this. trying to find a way without plugin or framedelay…
i’ll pay anyone who finds an easy solution which does that for how matter how many indices a huge drink at node!
does VL count? :)
elektromeiers plugin is very short in code, it was interesting to re-code it in VL to see how short one can express the same in a visual language. here an interesting new feature of the Loop called ‘Alive’ was used to filter out invalid combinations.
anyone knows other old and complicated patching threads?
if your interested, needs latest alpha of course:
UniqueCombinations.zip (15.9 kB)
could you please explain how the output values are generated?
I understand that values are sent to Contains HashSet, and if both are not already contained, then they are sent to Add HashSet (this operation is ruled by Add’s Enabled pin); but how Add influences the content of Item and Item 2’s output? Is it because they share the same type?
Please consider that I’m literally fighting to create another foreach loop that accepts as input Input and Input 2, so please be patient.
A few words about Alive would be great, too.
I was so determined to patch this that I spent a not insignificant amount of time before node.
I ended up with needing an obscene amount of swapdims and the likes and it just exploded in complexity, but I think it is possible… I would have loved to have gotten that huge drink at NODE, but I failed.
the For Each runs for all slices of the two inputs and the ‘Alive’ pad in the loop decides whether the slice of the current iteration will be in the output or not. its very similar to a Select node or the Where method in C#. By default it is invisible and always true, so all iterations of the loop will generate one slice of the output spread.
in this example it is only true if none of the input items of this iteration was found in the ‘Used List’.
you can create an ‘Alive’ pad by creating an output or accumulator writer and then click on replace->Alive in the context menu.
yeah this is the perfect example for vl, its possible in vvvv(see patch) but not without framedelay.
btw: is the triangle in the foreach-region a field? why it is not a dot? whats the difference to the dots?
first combination from list.v4p (51.3 kB)
the triangle is called accumulator, which is something like an internal field of the loop, you can input an initial value like the Empty (HashSet) in this case and then access it and modify it in each iteration of the loop. the final value is then available at the output.
your solution unfortunately still does not work with any combination.
VL + elektromeier solution:
Anyway, I’d say that a way to achieve this is to dynamically create groups of nodes performing determined tasks through SetPatch. This would probably avoid the framedelay.
Ok, it’s the Alive feature. Thanks.
Note to myself: the visual part of VL is more like an “helper” then an accurate definition of the logic, as opposed to vvvv.