October 2004
Intermediate to advanced
336 pages
6h 27m
English
This function is for those situations where a set of people, such as office coworkers, exchange gifts among themselves, with each person assigned to buy gifts for one other person.
This function walks the list of people and assigns a gift target to each of them. It has to ensure that no one is assigned his or her own name. In particular, with a list of N people, it needs to avoid the situation where the first N-1 people are chosen to give gifts among themselves and, when it is time to process the last person on the list, no one else is left.
The program is passed as a parameter a list of names, and returns a dictionary. In the ...
Read now
Unlock full access