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.
12 matches
Mail list logo