I am writing a program that can calculate all possible places for people sitting at a random amount of tables (can go up to 1000+):
As you see on the image, the black dots represent people (but in the computer, there are different types of people.) There are two types of tables : blue and pink ones. The blue ones can contain 3 people and the pink 2 people.
To get all possible places for any person to sit I could use foreach loops (8of them) and then I can run some extra code...
But what happens if I add 200 tables? Then do I need to use 200 foreach loops? Is there any way that this can be coded faster and less-space-consuming-coded?
What I tried? =>
switch(listoftables.Count)
{
case 1:foreach(Table table in listoftables){ //code to add people to this table}break;
case 2: foreach(Table table1 in listoftables)
{foreach(Table table1 in listoftables){//code to add people to this table
}}break;
}
INPUT : array with editable Table class objects (its a class created by myself) PROCESS : the above List is edited and is added to another List object, where after the whole foreach process has ended, the OUTPUT will write all possible configurations (who are in the other List object) to the screen.
Example part of output :
// List<Table> listofalltables was processed
List<listofalltables> output
=> contains as [0] in array : List first => contains as [0] in array : Table.attachedpeople (is list)