On Dec 1, 5:55 pm, Phlip wrote:
> Awesome thanks - but:
>
> > from itertools import imap,product
>
> Do we have a version for Python2.5? I have to support an older server
> here; can't install a newer python on it...
If you can get by with the performance of pure Python, a solution is
right in th
Awesome thanks - but:
> from itertools import imap,product
Do we have a version for Python2.5? I have to support an older server
here; can't install a newer python on it...
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Nov 18, 2009 at 4:58 PM, Phlip wrote:
> Python:
>
> I have a quaint combinatorics problem. Before I solve it, or find a
> solution among "generators", I thought y'all might like to show off
> any solutions.
>
> Given an array like this...
>
>
On Nov 18, 4:58 pm, Phlip wrote:
> Python:
>
> I have a quaint combinatorics problem. Before I solve it, or find a
> solution among "generators", I thought y'all might like to show off
> any solutions.
>
> Given an array like this...
>
>
Python:
I have a quaint combinatorics problem. Before I solve it, or find a
solution among "generators", I thought y'all might like to show off
any solutions.
Given an array like this...
[0, 4, 3]
Produce an array like this:
[
[0, 0, 0],
[0, 1, 0],
[0, 2, 0
On Feb 12, 7:52 am, Michael Robertson <[EMAIL PROTECTED]> wrote:
> Where is the python equivalent of:
>
> http://search.cpan.org/~fxn/Algorithm-Combinatorics-0.16/Combinatoric...
>
> combinations (with and without repetition)
> variations (with and without repetition)
>
* Michael Robertson (Mon, 11 Feb 2008 23:52:31 -0800)
> Where is the python equivalent of:
>
> http://search.cpan.org/~fxn/Algorithm-Combinatorics-0.16/Combinatorics.pm
>
> combinations (with and without repetition)
> variations (with and without repetition)
> permutations
In article <[EMAIL PROTECTED]>,
<[EMAIL PROTECTED]> wrote:
>Cameron Laird:
>> It does occur to me, though, that even more widely applicable
>> than the combinatorics module of Mathematica (if only because of
>> its licensing) might be such resources as
>
&g
On Feb 11, 11:52 pm, Michael Robertson <[EMAIL PROTECTED]>
wrote:
> Where is the python equivalent of:
>
> http://search.cpan.org/~fxn/Algorithm-Combinatorics-0.16/Combinatoric...
>
> combinations (with and without repetition)
> variations (with and without repetition)
>
Robert Dodier wrote:
> Cameron Laird wrote:
>
>> Should combinatorics be part of the standard library? That's
>> an aesthetic-pragmatic question I don't feel competent to
>> answer; I look to timbot and Guido and so on for judgment there.
>> It does oc
On Feb 12, 1:52 am, Michael Robertson <[EMAIL PROTECTED]> wrote:
> Where is the python equivalent of:
>
> http://search.cpan.org/~fxn/Algorithm-Combinatorics-0.16/Combinatoric...
>
> combinations (with and without repetition)
> variations (with and without repetition)
>
Cameron Laird:
> It does occur to me, though, that even more widely applicable
> than the combinatorics module of Mathematica (if only because of
> its licensing) might be such resources as
What I was trying to say is that that Mathematica combinatorics module
contains lots and lots an
Cameron Laird wrote:
> Should combinatorics be part of the standard library? That's
> an aesthetic-pragmatic question I don't feel competent to
> answer; I look to timbot and Guido and so on for judgment there.
> It does occur to me, though, that even more widely
In article <[EMAIL PROTECTED]>,
<[EMAIL PROTECTED]> wrote:
>Michael Robertson:
>> I'm guessing sage has this, but shouldn't something like this be part of
>> the standard library (perhaps in C)?
>
>My answer is positive. As a reference point y
int
>
> The problem seems to be that although python supports arbitrary long
> integers, all the internal loop counters still use limited size
> integers.
I'm curious what you think this has to do with the Original Poster's
question, which was about combinatorics (as the su
On Mon, 11 Feb 2008 23:52:31 -0800
Michael Robertson <[EMAIL PROTECTED]> wrote:
> Am I wishing on a star?
for i in xrange(10**10):
print i
OverflowError: long int too large to convert to int
The problem seems to be that although python supports arbitrary long
integers, all the internal loop
Michael Robertson:
> I'm guessing sage has this, but shouldn't something like this be part of
> the standard library (perhaps in C)?
My answer is positive. As a reference point you can look at the
combinatorics module of Mathematica.
Bye,
bearophile
--
http://mail.python.org/
Where is the python equivalent of:
http://search.cpan.org/~fxn/Algorithm-Combinatorics-0.16/Combinatorics.pm
combinations (with and without repetition)
variations (with and without repetition)
permutations
partitions
derangements
etc
I'm guessing sage has this, but shouldn't something
On Oct 25, 12:20 am, none <""atavory\"@(none)"> wrote:
> Hello,
>
> Is there some package to calculate combinatorical stuff like (n over
> k), i.e., n!/(k!(n - k!) ?
>
> I know it can be written in about 3 lines of code, but still...
>
> Thanks,
>
> Ami
http
none wrote:
> Is there some package to calculate combinatorical stuff like (n over
> k), i.e., n!/(k!(n - k!) ?
Yes, in SciPy.
Alan Isaac
>>> from scipy.misc.common import comb
>>> help(comb)
Help on function comb in module scipy.misc.common:
comb(N, k, exact=0)
Combinations of N thin
[EMAIL PROTECTED] wrote:
> On Oct 24, 5:20 pm, none <""atavory\"@(none)"> wrote:
>> Hello,
>>
>> Is there some package to calculate combinatorical stuff like (n over
>> k), i.e., n!/(k!(n - k!) ?
>
> Sure, the gmpy module.
>
Excellent, many thanks!
--
http://mail.python.org/mail
On Oct 24, 5:20 pm, none <""atavory\"@(none)"> wrote:
> Hello,
>
> Is there some package to calculate combinatorical stuff like (n over
> k), i.e., n!/(k!(n - k!) ?
Sure, the gmpy module.
>>> import gmpy
>>> for m in xrange(10):
for n in xrange(m+1):
print
Hello,
Is there some package to calculate combinatorical stuff like (n over
k), i.e., n!/(k!(n - k!) ?
I know it can be written in about 3 lines of code, but still...
Thanks,
Ami
--
http://mail.python.org/mailman/listinfo/python-list
Nic wrote:
> In my example I've chosen the number 3.
> How should I change the Python code in order to select another number
> (e.g. 7)?
Here is a parameterized render().
def render(w, h, suffixes="ab"):
pairs = list(unique(range(1, h+1), 2))
for item in unique(pairs, w):
for suf
Thanks a bunch.
Both the codes are fine.
Only one question, if you allow.
In my example I've chosen the number 3.
How should I change the Python code in order to select another number (e.g.
7)?
Thanks.
Nic
--
http://mail.python.org/mailman/listinfo/python-list
Nic wrote:
> Hello,
> I've a problem in defining a good Python code useful to articulate the
> following algorithm.
> Can you help me please?
> Thanks a bunch,
> Nic
>
> 1. Insert a number "n".
> Example: 3
>
> 2. List all the numbers < or = to n.
> Example: 1,2,3.
>
> 3. Combine the listed number
Nic wrote:
>> PS: Please don't top-post.
You probably overlooked that :-)
Here's a naive implementation:
from itertools import izip
def unique(items, N):
assert N > 0
if N == 1:
for item in items:
yield item,
else:
for index, item in enumerate(items):
I forgot them. Sorry.
They should be included.
Nic
"Peter Otten" <[EMAIL PROTECTED]> ha scritto nel messaggio
news:[EMAIL PROTECTED]
> Nic wrote:
>
> [Algorithm that I may have misunderstood]
>
>> 12a 13a 23a
>> 12a 13b 23a
>> 12a 13b 23b
>> 12b 13a 23a
>> 12b 13b 23a
>> 12b 13b 23b
>
> What abou
Nic wrote:
[Algorithm that I may have misunderstood]
> 12a 13a 23a
> 12a 13b 23a
> 12a 13b 23b
> 12b 13a 23a
> 12b 13b 23a
> 12b 13b 23b
What about 12a 13a 23b and 12b 13a 23b?
Peter
PS: Please don't top-post.
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
I've a problem in defining a good Python code useful to articulate the
following algorithm.
Can you help me please?
Thanks a bunch,
Nic
1. Insert a number "n".
Example: 3
2. List all the numbers < or = to n.
Example: 1,2,3.
3. Combine the listed numbers each other.
Example:
12
13
23
4.
YYUsenet wrote:
Xah Lee wrote:
(snip insanities)
Why are you posting this to comp.lang.python? This obviously has nothing
to do with python at all. If you are trying to teach people python,
claiming that "...let's do a python version. I'll post my version later
today." Isn't really the proper
David Eppstein's code is very nice.
Here's the python version of the perl code:
©# -*- coding: utf-8 -*-
©# Python
©
©def combo (n):
©'''returns all possible (unordered) pairs out of n numbers 1 to
n.
©
©Returns a dictionary. The keys are of the form "n,m",
©and their values are tuple
I am no longer resisting. As time goes, the nausea when I first saw Mr.
Lee's smelly "technical posts" is starting to fade. The discussion
group should have a high tolerance towards polymorphic people these
days.
--
http://mail.python.org/mailman/listinfo/python-list
Xah Lee wrote:
a year ago i wrote this perl program as part of a larger program.
as a exercise of fun, let's do a python version. I'll post my version
later today.
[code snipped]
This is Perl-Python a-day. To subscribe, see
http://xahlee.org/perl-python/python.html
Xah
[EMAIL PROTECTED]
http://xah
In comp.lang.perl.misc Xah Lee <[EMAIL PROTECTED]> wrote:
> a year ago i wrote this perl program as part of a larger program.
> sub combo ($) {
>my $max=$_[0];
>my %hh=();
>for (my $j=1; $j < $max; ++$j) {
>for (my $i=1; $i <= $max; ++$i) {
>my $m = (($i+$j)-1)%$ma
On Thu, Feb 10, 2005 at 02:51:24PM -0800, Xah Lee wrote:
> a year ago i wrote this perl program as part of a larger program.
>
> as a exercise of fun, let's do a python version. I'll post my version
> later today.
from probstat import Combination
There is something deeply wrong about plugging yo
In article <[EMAIL PROTECTED]>,
"Xah Lee" <[EMAIL PROTECTED]> wrote:
> combo(n) returns a collection with elements of pairs that is all
> possible combinations of 2 things from n. For example, combo(4)
> returns {'3,4' => ['3',4],'1,2' => [1,2],'1,3' => [1,3],'1,4' =>
> [1,4],'2,3' => ['2',3],'2,
a year ago i wrote this perl program as part of a larger program.
as a exercise of fun, let's do a python version. I'll post my version
later today.
=pod
combo(n) returns a collection with elements of pairs that is all
possible combinations of 2 things from n. For example, combo(4)
returns {'3,4
38 matches
Mail list logo