Subscribe to the activity stream RSS Feed
Homework: Lesson 1, HW 1in MIT OpenCourseWare 6.00 Introduction to Computer Science and ProgrammingProblem Set 0 Name: Peragon Time: 30 seconds first_name = raw_input('What is your first name? ')
last_name = raw_input('What is your last name? ')
print first_name
print last_name
|
|
Homework: Lesson 12, HW 1in MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming1) T(n)=O(n): the function will recurse until i=1 2) T(n)=O(n): each loop is constant and there is about n loop 3) T(n)=O(n): each loop is constant and there is about ... #5) def swap0([1], [2]): assert type(s1) == list and type(s2) == list tmp = s1[:] # tmp = [1] s1 = s2[:] # tmp = [1], s1 = [2] s2 = tmp # tmp = [1], s1 = [2], s2 = [1] return # [2],[1] #6) def swap1([1], [2] ): assert ... |
|
Homework: Lesson 11, HW 1in MIT OpenCourseWare 6.00 Introduction to Computer Science and ProgrammingWord games 2 Problem 4: i copy the function which find subset from BTheMad, thanks! this problem is really hard to comprehend what it is talking about. then i watch lecture 11 in which the prof. said the problem set ... # Problem Set 6: 6.00 Word Game
# Name: Joe Li
# Time: 8:30
#
import random
import string
import time
VOWELS = 'aeiou'
CONSONANTS = 'bcdfghjklmnpqrstvwxyz'
HAND_SIZE = 7
SCRABBLE_LETTER_VALUES = {
'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2 ...
|
|
Homework: Lesson 9, HW 2in MIT OpenCourseWare 6.00 Introduction to Computer Science and ProgrammingWord games # Problem Set 5: Ghost
# Name: Joe Li
# Time: 3:30
#
import random
# -----------------------------------
# Helper code
# (you don't need to understand this helper code)
import string
WORDLIST_FILENAME = "words.txt"
def load_words():
"""
Returns a list of valid words. Words are strings of ...
|
|
Homework: Lesson 9, HW 1in MIT OpenCourseWare 6.00 Introduction to Computer Science and ProgrammingWord games # Problem Set 5: 6.00 Word Game
# Name: Joe Li
# Time: 4:00
#
import random
import string
VOWELS = 'aeiou'
CONSONANTS = 'bcdfghjklmnpqrstvwxyz'
HAND_SIZE = 7
SCRABBLE_LETTER_VALUES = {
'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4 ...
|
|
Homework: Lesson 7, HW 1in MIT OpenCourseWare 6.00 Introduction to Computer Science and ProgrammingSimulating a retirement fund # Problem Set 4 # Name: Joe Li # Time: 4:15 # # Problem 1 # # Retirement fund # End of year 1 # F[0] = salary*save*0.01 # End of year 2 # F[1] = F[0]*(1+0.01*growthRate)+salary*save*0.01 # End ... |
|
Homework: Lesson 5, HW 1in MIT OpenCourseWare 6.00 Introduction to Computer Science and ProgrammingMatching strings: a biological perspective # Problem Set 3 (Part I)
# Name: Joe Li
# Time: 2:00
#
from string import *
def countSubStringMatch(target,key):
count=0
index=0
while find(target,key,index)!=-1: # while searching the target from index and find a key
index=find ...
|
|
Homework: Lesson 4, HW 1in MIT OpenCourseWare 6.00 Introduction to Computer Science and Programmingsorry, I didn't see it. move my work to the next lecture. |
|
Homework: Lesson 3, HW 1in MIT OpenCourseWare 6.00 Introduction to Computer Science and ProgrammingDiophantine equations # Problem Set 2 (Part I) # Name: Joe Li # Time: 4:00 # count=0 # the number of successive n McNuggets can be bought n=1 # n start from 1 a=0 # make a,b,c,recognizable b=0 c=0 while ... |
|
Homework: Lesson 2, HW 1in MIT OpenCourseWare 6.00 Introduction to Computer Science and ProgrammingComputing prime numbers, product of primes #Problem Set 1 (PART I)
#Name Joe Li
#Time 4:30
#
x=3 # candidate
d=2 # divisor
count=1 # the number of prime has been found
while count!=1000: # do the following utill the 1000th prime has been found
while ...
|
|
Homework: Lesson 1, HW 1in MIT OpenCourseWare 6.00 Introduction to Computer Science and ProgrammingA very simple program: entering and printing your name # Problem Set 0
# Name: Joe Li
# Time: 2:00
#
print("Enter your last name:")
last_name=raw_input()
print("Enter your first name:")
first_name=raw_input()
print(first_name)
print(last_name)
|
|
Homework: Lesson 9, HW 2in MIT OpenCourseWare 6.00 Introduction to Computer Science and ProgrammingThis was fun! import random
#---Helper code
import string
WORDLIST_FILENAME = "words.txt"
def load_words():
"""
Returns a list of valid words. Words are strings of lowercase letters.
Depending on the size of the word list, this function may
take a while to finish.
"""
print ...
|
|
Homework: Lesson 9, HW 1in MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming# Problem Set 5: 6.00 Word Game
# Name:
# Collaborators:
# Time:
#
import random
import string
VOWELS = 'aeiou'
CONSONANTS = 'bcdfghjklmnpqrstvwxyz'
HAND_SIZE = 7
SCRABBLE_LETTER_VALUES = {
'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j ...
|
|
Homework: Lesson 11, HW 1in MIT OpenCourseWare 6.00 Introduction to Computer Science and ProgrammingVery strange results in fast_pick =/ For some reason it takes too much time to generate all the sub-sets and this kills all the benefits from further access to dictionary. This version contains some profiling and launches both methods. # Problem Set 5: 6.00 Word Game
# Name:
# Collaborators:
# Time:
#
import random
import time
VOWELS = 'aeiou'
CONSONANTS = 'bcdfghjklmnpqrstvwxyz'
HAND_SIZE = 10
SCRABBLE_LETTER_VALUES = {
'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j ...
|
|
Homework: Lesson 9, HW 2in MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming# Problem Set 5: Ghost
# Name:
# Collaborators:
# Time:
#
import random
# -----------------------------------
# Helper code
# (you don't need to understand this helper code)
import string
WORDLIST_FILENAME = "words.txt"
def load_words():
"""
Returns a list of valid words. Words are strings of lowercase letters.
Depending ...
|
|
Homework: Lesson 9, HW 1in MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming
# Problem Set 5: 6.00 Word Game
# Name:
# Collaborators:
# Time:
#
import random
import string
VOWELS = 'aeiou'
CONSONANTS = 'bcdfghjklmnpqrstvwxyz'
HAND_SIZE = 7
SCRABBLE_LETTER_VALUES = {
'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j ...
|
|
Homework: Lesson 7, HW 1in MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming
#
# Problem 1
#
def nestEggFixed(salary, save, growthRate, years):
"""
- salary: the amount of money you make each year.
- save: the percent of your salary to save in the investment account each
year (an integer between 0 and 100).
- growthRate: the annual ...
|
|
Homework: Lesson 5, HW 1in MIT OpenCourseWare 6.00 Introduction to Computer Science and ProgrammingAs I remember, I took a really straightforward way of solving these problems =/ Test functions do all the calls. ###############
## Problem 1 ##
###############
from string import *
def count_sub_string_match(target, key):
"""Find all occurrences of a string in another"""
counter = 0
position = 0
pointer = 0
while(pointer < len(target)):
position = find(target, key, pointer)
if position != -1:
counter += 1
pointer = position + 1 ...
|
|
Homework: Lesson 4, HW 1in MIT OpenCourseWare 6.00 Introduction to Computer Science and ProgrammingMoved solution to the next lecture |
|
Homework: Lesson 3, HW 1in MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming# Problem 3
a = 1
b = 1
c = 1
eq = 6 * a + 9 * b + 20 * c
n = 200
max_a = n / 6 + 1
max_b = n / 9 + 1
max_c = n / 20 + 1
n_tuple = ()
for n in range(1, n):
for a in range ...
|