elz: (ada-tubes)
elz ([personal profile] elz) wrote in [community profile] intro_to_cs2009-11-11 10:52 pm
Entry tags:

Poll & solutions

First:

Open to: Registered Users, detailed results viewable to: All, participants: 25


Tickyboxes!

View Answers

Finished lecture 2
24 (96.0%)

Finished problem set 1
15 (60.0%)



Also, it occurs to me that it might be handy to have a place to post/discuss solutions to the problem sets, to see what we can learn from each other in the absence of TAs. If you actually go to MIT and the problem sets are still the same, don't read these. ;)

Fire away!
zulu: Carson Shaw looking up at Greta Gill (Default)

[personal profile] zulu 2009-11-17 01:49 am (UTC)(link)
Still working on problem 2, but I'm stuck because I can't sum logs. When I try, I get "Error: float required". I've tried assigning the answer as a float, but that doesn't work.

Are there any readings that go along with this week that might help?

Here's my test case:

from math import *
number = log(2)
print number # this works
primes = (2, 3, 5, 7, 11, 13) # this is just as a test case
number = 6
sum = sum(log(primes)) # this is where I get an error message
print sum
ratio = sum/number
print ratio
bellerina: (Default)

[personal profile] bellerina 2009-11-19 05:35 am (UTC)(link)
I think that you can't take the log of an array-- it's not distributive. I tried the same thing and got the error, so I ended up taking the log of each prime before I put them into the array. Not the most elegant solution, but it works...
zulu: Omar Epps, looking awesome (house - epps)

[personal profile] zulu 2009-11-19 03:33 pm (UTC)(link)
Ahh, thanks. I'll try that. Still stuck way back here and I think we have another lecture and problem set coming up...eep!