Fast generation of permutations
Wed Jan 25 19:03:09 CET 2006
Frode Øijord <frodo at sim.no> writes:
> > cards = range(52)
> > for (hand) in probstat.Combination(card, 5):
> > pass
> > Takes 1.3 seconds on my laptop instead of 17 seconds for the pure
> > python version which is only one order of magnitude faster.
> This is *exactly* what i wanted! I just installed it and the hand
> generation is down to around 1.2 seconds now, and that I can live with :)
Note that you're looking at 24x more hands than you really need to,
since poker hand evaluation doesn't change if you re-label the four
suits. It's not like bridge, where spades beat hearts and so forth.
More information about the Python-list