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
// http://www.akeric.com/blog/?p=1411 | |
// Eric Pavey - AkEric.com - 2010-12-29 | |
// Example showing simple multi-touch detection in 'Processing - Android'. | |
// My Samsung Captivate (Galaxy S) can track 5 touch-points. | |
// Updated to work with Processing's surfaceTouchEvent instead of | |
// Android's dispatchTouchEvent. | |
// Should point out that API Level 9 has MotionEvent.PointerCoords class that |
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
# A* Shortest Path Algorithm | |
# http://en.wikipedia.org/wiki/A* | |
# FB - 201012256 | |
from heapq import heappush, heappop # for priority queue | |
import math | |
import time | |
import random | |
class node: | |
xPos = 0 # x position |
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
# 6.00 Problem Set 10 | |
# Graph optimization | |
# | |
# A set of data structures to represent graphs | |
# | |
class Node(object): | |
def __init__(self, name): |
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 RandomWalkRobot(Robot): | |
""" | |
A RandomWalkRobot is a robot with the "random walk" movement strategy: it | |
chooses a new direction at random at the end of each time-step. | |
""" | |
def updatePositionAndClean(self): | |
""" | |
Simulate the raise passage of a single time-step. | |
Move the robot to a new position and mark the tile it is on as having |
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 1 | |
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
class RandomWalkRobot(Robot): | |
""" | |
A RandomWalkRobot is a robot with the "random walk" movement strategy: it | |
chooses a new direction at random at the end of each time-step. | |
""" | |
def updatePositionAndClean(self): | |
""" | |
Simulate the raise passage of a single time-step. | |
Move the robot to a new position and mark the tile it is on as having |
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 loadTemperatures(file): | |
lines = [line.strip() for line in open(file) if line[0].isdigit()] | |
data = [] | |
[data.insert(int(line.split()[0]), int(line.split()[1])) for line in lines] | |
return data | |
temps = loadTemperatures("julyTemps.txt") | |
producePlot(temps) |
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
<html><head> | |
<title>Udacity | Free Online Courses. Advance your College Education & Career</title> | |
<meta name="google-site-verification" content="8BozdrktZ5uY63LYrPxB5iOkouVTdHipGsNzUW9V2pU"> | |
<meta property="og:title" content="Udacity | Free Online Courses, Advance your College Education & Career"> | |
<meta property="og:type" content="website"> | |
<meta property="og:url" content="http://www.udacity.com/"> | |
<meta property="og:image" content="http://www.udacity.com/media/img/logos/Udacity_logo.png"> | |
<meta property="og:image:type" content="image/png"> | |
<meta property="og:image:width" content="89"> | |
<meta property="og:image:height" content="98"> |
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
# This works | |
def isWordIn(word, text): | |
for sign in string.punctuation: | |
if (sign in text): | |
text = text.replace(sign, '') | |
print(text) | |
words = (text.lower()).split() | |
print(words) | |
return word in words |
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 buildCoder(shift): | |
dict_letters = {} | |
for letter in string.ascii_letters: | |
dict_letters[letter] = letter | |
for letter in dict_letters: | |
if (string.ascii_letters.find(letter) + shift) in range (0, 52): | |
# | |
dict_letters[letter] = string.ascii_letters[(string.ascii_letters.find(letter) + shift) % 52] | |
else: |
NewerOlder