On Sat, Jun 20, 2009 at 1:01 PM, Paul McGuire<pt...@austin.rr.com> wrote: > If you are looking for all possible 60-card deals of this deck, then you > also probably want to filter out duplicate deals caused by equivalent cards > exchanging places. That is, say you had a deck of 3 cards: 2 Mountain, and > 1 Vial, and you want to deal out al 3 in various order of cards. Using the > recursive solutions, you will get: > > (hmm, couldn't get either of the previous submissions to work..., well > something like this) > > ['Mountain', 'Mountain', 'Vial'] > ['Mountain', 'Vial', 'Mountain'] > ['Mountain', 'Mountain', 'Vial'] > ['Mountain', 'Vial', 'Mountain'] > ['Vial', 'Mountain', 'Mountain'] > ['Vial', 'Mountain', 'Mountain']
No, my solution does not generate that list. It generates ['Vial', 'Vial', 'Vial'] ['Mountain', 'Vial', 'Vial'] ['Mountain', 'Mountain', 'Vial'] > That is, because you have 2 Mountain cards, recursively shuffling this list > *looks* like you have two different list elements to process, but in fact, > they are equivalent so you will get duplicate deals. My solution does not shuffle. It picks each possible number of the first card, then recursively constructs all possible decks from the remaining card . Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor