Nested For Loop Without Repetitions! PLEASE HELP
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Austin Welch
am 29 Jun. 2018
Kommentiert: Austin Welch
am 29 Jun. 2018
My problem is that I have a array of strings, which are names, that can vary in length depending on how many the user inputs. I am okay up until that point, but I also want to store every combination of six of the names in the array. I was using six nested loops that ran from one to the number of names so that it would run through all combinations of the names. The issues are that with that method, the same name can show up multiple times in a collection of six name, the same combination of people can show up just in a different order, and it seems to take a long time.
I was trying to get rid of the same name showing up in the same grouping of six people with an if statement, but it seems tedious and also adds time. There are normally around 20 people inputted so that would be 64,000,000 different combinations if I did not filter out the repeated names and repeated groups. This just takes a lot of time because I am also trying to add if statements for specific characteristics of the people, which again adds more time.
Anyways, I would greatly appreciate if someone had a efficient way to run through every combination of picking six people from the group with no repeated names in each group and no repeated groups overall.
I have been trying to figure this out for a long time now and just can't wrap my mind around it, so if someone knows an answer please help! Thanks so much!
1 Kommentar
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!