This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getAvailableLetters(lettersGuessed): | |
''' | |
lettersGuessed: list, what letters have been guessed so far | |
returns: string, comprised of letters that represents what letters have not | |
yet been guessed. | |
''' | |
# FILL IN YOUR CODE HERE... | |
L2 = [] | |
import string | |
for c in string.ascii_lowercase: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getGuessedWord(secretWord, lettersGuessed): | |
''' | |
secretWord: string, the word the user is guessing | |
lettersGuessed: list, what letters have been guessed so far | |
returns: string, comprised of letters and underscores that represents | |
what letters in secretWord have been guessed so far. | |
''' | |
count = 0 | |
blank = ['_'] * len(secretWord) | |
#print blank |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hangman(secretWord): | |
''' | |
secretWord: string, the secret word to guess. | |
Starts up an interactive game of Hangman. | |
* At the start of the game, let the user know how many | |
letters the secretWord contains. | |
* Ask the user to supply one guess (i.e. letter) per round. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def compChooseWord(hand, wordList): | |
""" | |
Given a hand and a wordList, find the word that gives | |
the maximum value score, and return it. | |
This word should be calculated by considering all the words | |
in the wordList. | |
If no words in the wordList can be made from the hand, return None. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def findBestShift(wordList, text): | |
""" | |
Finds a shift key that can decrypt the encoded text. | |
text: string | |
returns: 0 <= int < 26 | |
""" | |
### TODO | |
bestShift=0 | |
ValidWords=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RectangularRoom(object): | |
""" | |
A RectangularRoom represents a rectangular region containing clean or dirty | |
tiles. | |
A room has a width and a height and contains (width * height) tiles. At any | |
particular time, each of these tiles is either clean or dirty. | |
""" | |
def __init__(self, width, height): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# === Problem 3 | |
def runSimulation(num_robots, speed, width, height, min_coverage, num_trials, | |
robot_type): | |
""" | |
Runs NUM_TRIALS trials of the simulation and returns the mean number of | |
time-steps needed to clean the fraction MIN_COVERAGE of the room. | |
The simulation is run with NUM_ROBOTS robots of type ROBOT_TYPE, each with | |
speed SPEED, in a room of dimensions WIDTH x HEIGHT. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enter your code for runSimulation in this box. | |
def runSimulation(num_robots, speed, width, height, min_coverage, num_trials, | |
robot_type): | |
""" | |
Runs NUM_TRIALS trials of the simulation and returns the mean number of | |
time-steps needed to clean the fraction MIN_COVERAGE of the room. | |
The simulation is run with NUM_ROBOTS robots of type ROBOT_TYPE, each with | |
speed SPEED, in a room of dimensions WIDTH x HEIGHT. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def insert(atMe, newFrob): | |
""" | |
atMe: a Frob that is part of a doubly linked list | |
newFrob: a Frob with no link | |
This procedure appropriately inserts newFrob into the linked list that atMe is a part of. | |
""" | |
# Your Code Here | |
if newFrob.myName() < atMe.myName(): | |
if atMe.getBefore() == None: | |
atMe.setBefore(newFrob) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# comments.js.coffee | |
jQuery -> | |
# Create a comment | |
$(".comment-form") | |
.on "ajax:beforeSend", (evt, xhr, settings) -> | |
$(this).find('textarea') | |
.addClass('uneditable-input') | |
.attr('disabled', 'disabled'); | |
.on "ajax:success", (evt, data, status, xhr) -> | |
$(this).find('textarea') |