"Dinesh B Vadhia" <[EMAIL PROTECTED]> wrote
Hi! Say, I've got a numpy array/matrix of the form:
[[1 6 1 2 3]
[4 5 4 7 0]...
[2 1 0 5 6]]
I want to create a dictionary of rows (as the keys) mapped
to lists of non-zero numbers in that row
Caveat, I dont know about numpy arrays.But assuming
Alan
Thanks but I've been a bit daft and described the wrong problem which is easy
to solve the long way. Starting again ...
Given a (numpy) array how do you create a dictionary of lists where the list
contains the column indexes of non-zero elements and the dictionary key is the
row index.
This is from the MIT Opencourseware intro to computer science course,
which I've been working my way through. I understand what needs to be
done (I think), which is basically to test each possibility and return
the list of states with the most electoral votes that can be paid for
under the camp
A very interesting problem. Given this is homework, I
am not sure what it is you want.
Do you want the solution coded and tested?
Do you want this to include two or three algorithms optimized for speed
as well as accuracy?
I think the problem is well enough defined so that you do not need an
I'm actually not enrolled in the course; MIT puts some of its course
materials available online as a general resource. I am out of school
and trying to teach myself python on my own. I'm very much a beginner,
and since I'm not privy to the lectures or notes from this course I
have to fill in th
First, thank you for the explanation.
I admire your desire to learn bull riding by jumping on the monster's
back. The problem with assignments based on a course is that many
professors and associates have learned the only way to insure student
class attendance is to obfuscate the assignment
That it is.
Jaggo wrote:
Lol. And here I said to myself only, "What a nice
challenge".
On Sun, Sep 21, 2008 at 10:28 PM, Robert
Berman <[EMAIL PROTECTED]>
wrote:
A very interesting problem. Given this is
homework, I
am not sure what it is you want.
Do you want the sol
On Sun, Sep 21, 2008 at 2:17 PM, Dinesh B Vadhia
<[EMAIL PROTECTED]> wrote:
> Given a (numpy) array how do you create a dictionary of lists where the list
> contains the column indexes of non-zero elements and the dictionary key is
> the row index. The easy way is 2 for loops ie.
>
> import numpy
Here is another writeup on __new__() and __init__();
http://www.voidspace.org.uk/python/weblog/arch_d7_2008_09_20.shtml#e1014
Kent
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Try to put a 'r' letter before the opening-quote:
print \
r"""
_ ___ ___ ___ _
/ ___| / | / |/ || ___|
| |/ /| |/ /| /| || |__
| | _/ __| | / / |__/ | || __|
| |_| | / / | | / / | || |___
\_/ /_/ |
Thanks for the link it's really useful :)
On Mon, Sep 22, 2008 at 2:10 AM, Robert Berman <[EMAIL PROTECTED]>wrote:
> That it is.
>
> Jaggo wrote:
>
> Lol. And here I said to myself only, "What a nice challenge".
>
> On Sun, Sep 21, 2008 at 10:28 PM, Robert Berman <[EMAIL PROTECTED]>wrote:
>
>>
11 matches
Mail list logo