elz: (ada-tubes)
[personal profile] elz posting in [community profile] intro_to_cs
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!

Date: 2009-11-12 05:52 am (UTC)
ungemmed: (Default)
From: [personal profile] ungemmed
argh, Dreamwidth keeps on choking on my solution for problem 2! I guess it's reading the code as some malicious hacking attempt or something.

Date: 2009-11-12 06:18 am (UTC)
badgerbag: (Default)
From: [personal profile] badgerbag
try wrapping it in
  or  tags maybe...

Date: 2009-11-12 06:24 am (UTC)
ungemmed: (Default)
From: [personal profile] ungemmed
Thanks! It actually turned out, though, that NoScript was being overzealous and thought Dreamwidth was trying to hack me. o.O

Date: 2009-11-12 06:25 am (UTC)
ungemmed: (Default)
From: [personal profile] ungemmed
Problem 2
import math

n = int(raw_input('n? '))

primes = [2]
x = 3
logs = 0
while x <= n:
    divisible = False
    root = math.sqrt(x)
    for y in primes:
        if x % y == 0:
            divisible = True
            break
        if y > root:
            break
    if not divisible:
        logs += math.log(x)
        primes.append(x)
    x += 2
print logs
print logs / n

Profile

Introduction to Computer Science

July 2010

S M T W T F S
    123
45678910
11121314151617
18192021222324
2526272829 3031

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 12th, 2025 03:04 pm
Powered by Dreamwidth Studios