Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootcamp stuff #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions exercises-hello/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#
# This is your first python program!
# print out "hello world" to the terminal.
#
# When you are done, run the program with: python hello.py
#
# Run ./test.sh to make sure your program matches our expected output.
#
# TODO: write your code below

print("hello world")
#
2 changes: 2 additions & 0 deletions exercises-hello/script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env python
print "this is a python script!"
23 changes: 18 additions & 5 deletions exercises-spellchecker/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dictionary", we mean English dictionary).
"""


def load(dictionary_name):
"""
Opens the file called `dictionary_name` and returns
Expand All @@ -15,23 +16,35 @@ def load(dictionary_name):

Each line in the file contains exactly one word.
"""
# TODO: remove the pass line and write your own code
pass
global counter
counter = 0
wordlist=[[] for x in range(2000)]
with open(dictionary_name) as words:
for word in words:
stripword = word.strip()
wordhash = hash(stripword) % 2000
wordlist[wordhash].append(stripword)
counter = counter + 1
return wordlist


def check(dictionary, word):
"""
Returns True if `word` is in the English `dictionary`.
"""
pass
return (word in dictionary[(hash(word.lower())%2000)])

def size(dictionary):
"""
Returns the number of words in the English `dictionary`.
"""
pass
return counter

def unload(dictionary):
"""
Removes everything from the English `dictionary`.
"""
pass
for subdict in dictionary:
for word in subdict:
subdict.remove(word)
dictionary.remove(subdict)