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
require 'date' | |
require 'csv' | |
#Given a csv file output from Sermo App at https://app.sermo.com/reporting/reports/post_summary_by_date | |
#we need a csv of the posts in order of popularity, with the addition of a bayesian average to respond to different days. | |
#constructor of my post object with the csv fields to hold all the attributes | |
class Post < | |
# a post has csv categories a-q |
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
require 'date' | |
require 'csv' | |
class Post < | |
# a Person has a first name, last name, and city | |
Struct.new(:title, :link, :cats, :publish_date, :avg_rating, :comments, :votes, :username, :specialty, :pop) | |
end |
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
require 'date' | |
require 'csv' | |
#Given a csv file output from Sermo App at https://app.sermo.com/reporting/reports/post_summary_by_date | |
#we need a csv of the Post Promo contest winners (base $15 and grand prize $30) by the week's targeted specialties. | |
#We need to only pay members once, and only pay them for posts which received 10 comments and an average rating of at least 3 stars. | |
#Specialties targeted were sent an automated e-mail from Exact Target to remind them it was their day to participate. | |
#You will only need to tell this program what the file name from the Sermo app was, and it will output a payment csv file for you! | |
#constructor of my post object with the csv fields to hold all the attributes |
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 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 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. |
OlderNewer