Generating all combinations
mensanator at aol.com
Fri Jun 5 02:10:33 EDT 2009
On Jun 4, 10:25�pm, Steven D'Aprano
<ste... at REMOVE.THIS.cybersource.com.au> wrote:
> 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 would expect that. That was supposed to be funny. :-)
> 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.
I didn't know all of them either. I had to look
them up in the source code of the combinatorics
library I wrote for myself (I use that stuff a
lot in my research). BTW, I really appreciate the
links posted a while ago on how to search for text
in .py files on Windows. Could not have found them
otherwise. I must have a dozen copies of the module
on each of 4 disks (two hard & 2 flash) but the
comments containing those formulae was only in a
There was a subtle point. A function that would
return such counts is fine - provided you don't
have to actually count them! I'm sure Mr. Hettinger
More information about the Python-list