jillgoslinga


Joined 1 year ago
Homeworks submitted:
Homework comments:
3
0

About Me

jillgoslinga.com

Classes

MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming

Class status: Established
Role: Student
. 17% complete

Submitted Assignments

MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming: Lesson 3, HW 1

2.1, 2.2, 2.3, and 2.4 (Sorry, maybe I'll go back and explain my logic when I have more time / want to make my answers more complete.)

I'm excited I could get through these (2.3 and 2.4) without any hints / help from min bror this time!

#PS 2.1
#Jill Ann

Where sets of 6-McNuggets = a,
  and sets of 9-McNuggets = b,
  and sets of 20-McNuggets = c,

for:
        n = 50: a=2, b=2, c=1
        n = 51: a=4, b=3, c=0
        n = 52: a=2, b=0, c=2
        n = 53: a=1, b=3, c=1
        n = 54: a=0, b=6, c=0
        n = 55: a=1, b=1, c=2


#PS 2.2
#Jill Ann

        
Where the smallest possible number McNuggets in a single box is "a", any sequence of total (n) McNuggets n, n+1, ... until n+a allows purchase of any infinite exact numbers of McNuggets beyond the given n.
If a bunch of combinations are possible, and the difference between the smallest total transfatpacks and largest total transfatpacks in the combinations is the size of the smallest box, adding the smallest box to each subsequent combination will repeat the "flush" of possible patty combinations to infinity and beyond!


#PS 2.3
#Jill Ann

testnumber=1
countconsecutive=0
while countconsecutive<=6:
        match=False
        for samplea in range(0,testnumber):
                for sampleb in range(0,testnumber):
                        for samplec in range(0,testnumber):
                                if 6*samplea + 9*sampleb + 20*samplec == testnumber:
                                        match=True
                                        print `testnumber` + " matches with a=" + `samplea` + ", and b=" + `sampleb` + ", and c=" + `samplec`
                                        testnumber+=1
        if match == True:
                countconsecutive+=1
        if match == False:
                print `testnumber` + " is not a match"
                highestunmatched = testnumber
                testnumber +=1
                countconsecutive=0
print `highestunmatched` + " is the largest number of McNuggets that cannot be bought in exact quantity."

smallest=raw_input("How many McNuggets are in the smallest box you can buy? ")
medium=raw_input("How many McNuggets are in the 2nd smallest box you can buy? ")
largest=raw_input("How many McNuggets are in the largest box you can buy? ")


McDsizes = ( smallest, medium, largest )
a = int(McDsizes [0])
b = int(McDsizes [1])
c = int(McDsizes [2])
print a, b, c

testnumber=1
countconsecutive=0
while countconsecutive<=a:
        if testnumber < 200:
                match=False
                for samplea in range(0,testnumber):
                        for sampleb in range(0,testnumber):
                                for samplec in range(0,testnumber):
                                        if a*samplea + b*sampleb + c*samplec == testnumber:
                                                match=True
                                                #print `testnumber` + " matches with a=" + `samplea` + ", and b=" + `sampleb` + ", and c=" + `samplec`
                                                testnumber+=1
                if match == True:
                        countconsecutive+=1
                if match == False:
                        #print `testnumber` + " is not a match"
                        highestunmatched = testnumber
                        testnumber +=1
                        countconsecutive=0
print `highestunmatched` + " is the largest number of McNuggets that cannot be bought in an exact quantity."

jillgoslinga 4 months ago
MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming: Lesson 1, HW 1

PS 0

#PS 0
#Jill Ann

def namez():
   last = raw_input ("Wats ur last nameee? ")
   first = raw_input ("Waddya called ? ")
   print first, last

jillgoslinga 4 months ago
MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming: Lesson 2, HW 1

PS 1.1 / 1.2

#PS 1
#Jill Ann

#Problem set 1.1
def countPrime(n):
        x=2
        count=1
        while count<=n:
                prime=True
                for test in range (2,x):
                        if x%test == 0:
                                prime=False
                if prime==True:
                        count+=1
                if count<=n:
                        x+=1
        print `x` + " is the nth prime"




#Problem set 1.2
import math
x=2
count=1
logtable=0
while count<=1000:
        prime=True
        for test in range(2,x):
                if x%test ==0:
                        prime=False
        if prime==True:
                count+=1
                logtable+=math.log(x)
        if count <=1000:
                x+=1
print `x` + " is our final prime, ladies and gentlemen"
print `count-1` + " is the total count"
print `logtable` + " is the sum of the natural logs, per assignment"



jillgoslinga 4 months ago