Generating all combinations

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Thu Jun 4 23:25:16 EDT 2009


On Thu, 04 Jun 2009 09:47:05 -0700, Mensanator wrote:

> After all, everybody knows that for m items taken n at a time, the
> counts are
> 
> perm  w/repl = m**n
> comb  w/repl = (m+n-1)!/(n!(m-1)!)
> perm wo/repl = m!/(m-n)!
> comb wo/repl = m!/(n!(m-n)!)


"Everybody" knows? Be careful with those sweeping generalizations. 
Combinatorics is a fairly specialized area not just of programming but 
mathematics as well. 

I've done a spot poll of four developers here (two juniors and two 
seniors) and *not one* could give all four formulae correctly first go. 
One guy didn't recognize the terms (although on being reminded, he got 
two of the four formula). Another one, a self-professed maths-geek, 
worked them out from first principles.


-- 
Steven



More information about the Python-list mailing list