On Thu, 04 Jun 2009 23:10:33 -0700, Mensanator wrote:
>> "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 knew that! I was
On Jun 4, 10:25�pm, Steven D'Aprano
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 =
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
On Jun 4, 1:27 am, Raymond Hettinger wrote:
> > Nice one!
>
> It only does partitions of a sequence. I haven't yet looked at a way
> to
> do partitions of a set. Any ideas?
>
> > Raymond, as perhaps *the* principle contributor to itertools, do you feel
> > that the combinatorics-related tools sh
> Nice one!
It only does partitions of a sequence. I haven't yet looked at a way
to
do partitions of a set. Any ideas?
> Raymond, as perhaps *the* principle contributor to itertools, do you feel
> that the combinatorics-related tools should be in their own module? Or is
> that dividing the mod
On Jun 3, 10:53�pm, Steven D'Aprano
wrote:
> On Wed, 03 Jun 2009 18:21:37 -0700, Mensanator wrote:
>
> [mass snippage]
> Settle down Mensanator! Don't take it so personally! You're sounding
> awfully agitated.
Don't worry, I'm not.
>
> Now that I've narrowed down what you actually meant, I'm ha
On Wed, 03 Jun 2009 18:21:37 -0700, Mensanator wrote:
[mass snippage]
> What I *was* talking about is this quote from the 3.1 What's New page:
>
>
> The itertools.combinations_with_replacement() function is one of four
> for generating combinatorics including permutations and Cartesian
> product
On Wed, 03 Jun 2009 20:27:56 -0700, Raymond Hettinger wrote:
>> > What, no partitions?
>>
>> >http://en.wikipedia.org/wiki/Partition_of_a_set
>
> Simpler version:
>
> def partition(s):
> n = len(s)
> parts = range(1, n)
> for i in range(n):
> for div in combinations(parts, i)
> > What, no partitions?
>
> >http://en.wikipedia.org/wiki/Partition_of_a_set
Simpler version:
def partition(s):
n = len(s)
parts = range(1, n)
for i in range(n):
for div in combinations(parts, i):
print map(s.__getslice__, chain([0], div), chain(div,
[n]))
>>> pa
> What, no partitions?
>
> http://en.wikipedia.org/wiki/Partition_of_a_set
Seems like you could roll your own (using combinations as a starting
point):
def pairwise(iterable):
a, b = tee(iterable)
next(b, None)
return izip(a, b)
def partition(s):
n = len(s)
for i in range(n):
On Jun 3, 6:57 pm, Steven D'Aprano wrote:
> On Mon, 01 Jun 2009 22:20:16 -0700, Mensanator wrote:
> >> Are you sure that permutations and combinations are subsets of the
> >> Cartesian Product?
>
> > Sure looks that way (SQL examples):
> [snip]
> > I couldn't do that if they weren't subsets.
>
> P
On Mon, 01 Jun 2009 22:20:16 -0700, Mensanator wrote:
>> Are you sure that permutations and combinations are subsets of the
>> Cartesian Product?
>
> Sure looks that way (SQL examples):
[snip]
> I couldn't do that if they weren't subsets.
Permutations and combinations are arrangements of a singl
Mensanator wrote:
I couldn't do that if they weren't subsets.
Right. Sometimes one just has to assume things are different even if
they look the same on the surface. That is because else one wouldn't be
able to produce the other generators. I guess it would also work the
other way around, a
On Jun 1, 8:28 pm, Steven D'Aprano wrote:
> On Mon, 01 Jun 2009 17:24:49 -0700, Mensanator wrote:
> > On Jun 1, 6:40 pm, Steven D'Aprano > cybersource.com.au> wrote:
> >> On Mon, 01 Jun 2009 11:23:35 -0700, Mensanator wrote:
> >> > I believe the name you're looking for is
> >> > combinations_with
On Jun 1, 8:28�pm, Steven D'Aprano wrote:
> On Mon, 01 Jun 2009 17:24:49 -0700, Mensanator wrote:
> > On Jun 1, 6:40�pm, Steven D'Aprano > cybersource.com.au> wrote:
> >> On Mon, 01 Jun 2009 11:23:35 -0700, Mensanator wrote:
> >> > I believe the name you're looking for is
> >> > combinations_with
On Mon, 01 Jun 2009 17:24:49 -0700, Mensanator wrote:
> On Jun 1, 6:40 pm, Steven D'Aprano cybersource.com.au> wrote:
>> On Mon, 01 Jun 2009 11:23:35 -0700, Mensanator wrote:
>> > I believe the name you're looking for is
>> > combinations_with_replacement. It is one of the features being added
>>
On Jun 1, 6:40 pm, Steven D'Aprano wrote:
> On Mon, 01 Jun 2009 11:23:35 -0700, Mensanator wrote:
> > I believe the name you're looking for is combinations_with_replacement.
> > It is one of the features being added to 3.1 which should give all the
> > subsets of the Cartesian Product:
>
> > permu
On Mon, 01 Jun 2009 11:23:35 -0700, Mensanator wrote:
> I believe the name you're looking for is combinations_with_replacement.
> It is one of the features being added to 3.1 which should give all the
> subsets of the Cartesian Product:
>
> permutations_with_replacement:product()
> combinatio
On Jun 1, 10:11 am, pataphor wrote:
> Johannes Bauer wrote:
> > Any help is appreciated!
>
> This is on the fringe of exploitation, but hey, maybe the code helps you
> think about the algorithm.
>
> IMHO the following code is a glaring complaint about the injustice of
> omission itertools inflicts
Johannes Bauer wrote:
Any help is appreciated!
This is on the fringe of exploitation, but hey, maybe the code helps you
think about the algorithm.
IMHO the following code is a glaring complaint about the injustice of
omission itertools inflicts on the perfectly natural and obvious
procedu
member thudfoo wrote:
On 5/31/09, Scott David Daniels wrote:
Johannes Bauer wrote:
I'm trying to write a function in Python which ...
Look here:
http://docs.python.org/library/itertools.html#itertools.product
(new in 2.6, but code works in lower versions).
How would one go about installin
On 5/31/09, Scott David Daniels wrote:
> Johannes Bauer wrote:
>
> > Hello group,
> >
> > I'm trying to write a function in Python which does the following: For a
> > number of arguments which are all lists, return a list (or generator)
> > which yields all tuples of combination. E.g:
> >
>
> Loo
On May 31, 9:23 pm, Johannes Bauer wrote:
> I'm trying to write a function in Python which does the following: For a
> number of arguments which are all lists, return a list (or generator)
> which yields all tuples of combination. E.g:
>
> foofunction()
> # returns [ ]
Are you sure that's what yo
Johannes Bauer wrote:
Hello group,
I'm trying to write a function in Python which does the following: For a
number of arguments which are all lists, return a list (or generator)
which yields all tuples of combination. E.g:
Look here:
http://docs.python.org/library/itertools.html#itertools.pr
Hello group,
I'm trying to write a function in Python which does the following: For a
number of arguments which are all lists, return a list (or generator)
which yields all tuples of combination. E.g:
foofunction()
# returns [ ]
foofunction([1, 2, 3])
# returns [ (1), (2), (3) ]
foofunction([1,
25 matches
Mail list logo