Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a list of people:

Column A:

person A,             
person A guest,       
person B,            
person C,            
person C guest,     

Column B:


So in column A there is the person's name, column B gives a person a unique ID (the same id for their guest so we know that they are together).

Now pretend we have a list of 100 people (also note that not all persons have guests) and we have to seat them. We have a list of tables (for example 10 * 4 person table and 10*6 person tables). We have to randomize that each person is assigned to a table and the guest is seated on the same table.

What is the best way to do this? (it is also needed that I can generate this 4 times in a row without the same results, so when during the 4 courses of the diner the person are switching tables but not losing their guest).

share|improve this question
Quite a complex set of requirements, but to start with I'd be looking to use RANDBETWEEN. Did you manage to do what you wanted? –  Andi Mohr Jan 29 '13 at 12:44
You can not randomize 100 values AND ensure a different partners at each table change. You can either randomize, or you can sort. If you are going to sort you need to identify how many tables with what seating are available. –  James Jenkins Apr 15 '13 at 19:00
how many guests can a person have? –  Djerry Apr 19 '13 at 11:43
@James: That’s a bit of an oversimplification. I can deal five cards from a deck and get five random cards. Same goes for the lottery machines that select a handful of different Ping-Pong balls from a bucketful. In principle it’s straightforward to say, “OK, I’ve done that; now let me randomly select from the N-1 other possible outcomes.” In practice, this may reduce to keeping track of all the results you’ve gotten so far and comparing each new one to it (and iterating until you get one that’s different). –  Scott May 16 '13 at 23:56
@Jo: What, exactly, do you mean by “without the same results”? Is it good enough that no table at seating j completely matches a table at seating i (i, j ∈ {1,2,3,4})? Or is it good enough that party X and party Y not sit at the same table in multiple seatings? –  Scott May 16 '13 at 23:57

1 Answer 1

First, perform a countif and identify the total number of seats needed per person. Second, sort the people by count, high to low. Third, since you haven't provided a list of table constraints, assign the largest group to the largest table, then try to fill the remaining seats with a matching total for persons then continue on to the next table.

for example: Table for 6 would be group of 4 plus group of 2 or 2 groups of 3.

Since groups are likely to talk among themselves. Try to avoid placing singles with groups larger than 2.

If you can provide a list of seating constraints (# of tables and seats per table) this recommendation could be improved.

share|improve this answer
That’s a good start, but the word “random”, which was featured prominently in the question and the comments on it, does not appear in your answer. Neither do you address how to do this multiple (e.g., four) times and get a different result each time. –  Scott May 16 '13 at 23:58
To randomize the data, I'd need to know the table constraints. Since only partial data was provided. I left the first half of the answer. Which I did address. –  B-Rell May 17 '13 at 1:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.