I'm having trouble opening a file in linux, whose path has spaces in it.
$ mkdir my\ test
$ echo test > my\ test/test.txt
$ python
>>> open('./my test/test.txt')
Exception
>>> open('./my\\ test/test.txt')
Exception
but yet...
>>> import os
>>> os.chdir('./my test')
>>> open('./test')
works ju
[EMAIL PROTECTED] wrote the following on 02/28/2008 12:36 AM:
> On Feb 27, 8:47 pm, Michael Robertson <[EMAIL PROTECTED]> wrote:
> Your only casualty here is all the zeroes in (4,0,0,..). You don't
> want to swap k_2 and k_3 in (4,0,0). (Is that what permutation
> means
[EMAIL PROTECTED] wrote the following on 02/27/2008 08:46 PM:
> Just sort the list in text-ascending order, and it's pretty clear.
Indeed. After trying Mark's solution, I saw that it sorted in a very
nice manner.
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote the following on 02/27/2008 08:14 PM:
> On Feb 27, 10:12 pm, [EMAIL PROTECTED] wrote:
>>> For n=4, k=3, there are (4+3-1)!/(3-1)!/4! = 15 ways.
>>> (0,0,4)
>>> (0,4,0)
>>> (4,0,0)
>>> (0,2,2)
>>> (2,0,2)
>>> (2,2,0)
>>> (0,1,3)
>>> (0,3,1)
>>> (3,0,1)
>>> (3,1,0)
>>> (1,1,2
Michael Robertson wrote the following on 02/27/2008 06:40 PM:
> I need a generator which produces all ways to place n indistinguishable
> items into k distinguishable boxes.
I found:
http://portal.acm.org/citation.cfm?doid=363347.363390
Do anyone know if there are better algorithms tha
Roy Smith wrote the following on 02/27/2008 06:56 PM:
> What course is this homework problem for?
None. I assume you have an answer to this *trivial* problem...
It's actually a very general question relating to a very specific
problem I am working on. Normally, I do not reply to such snide
re
Michael Robertson wrote the following on 02/27/2008 06:40 PM:
> Hi,
>
> I need a generator which produces all ways to place n indistinguishable
> items into k distinguishable boxes.
>
My first thought was to generate all integer partitions of n, and then
generate all pe
Hi,
I need a generator which produces all ways to place n indistinguishable
items into k distinguishable boxes.
For n=4, k=3, there are (4+3-1)!/(3-1)!/4! = 15 ways.
(0,0,4)
(0,4,0)
(4,0,0)
(0,2,2)
(2,0,2)
(2,2,0)
(0,1,3)
(0,3,1)
(3,0,1)
(3,1,0)
(1,1,2)
(1,2,1)
(2,1,1)
The generator needs t
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 like this