This file contains hidden or 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 new_edge_point(self): | |
| side = random.randint(1,4) | |
| if side == 1: | |
| #left side | |
| return Vector(0, random.randint(0, constants.window_height)) | |
| elif side == 2: | |
| #right side | |
| return Vector(constants.window_width, random.randint(0, constants.window_height)) | |
| elif side == 3: | |
| #top |
This file contains hidden or 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
| import sys | |
| mapping = { | |
| 'a':'y', | |
| 'b':'h', | |
| 'c':'e', | |
| 'd':'s', | |
| 'e':'o', | |
| 'f':'c', | |
| 'g':'v', |
This file contains hidden or 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 SpellCheck(object): | |
| def __init__(self): | |
| self.trigram_store = {} | |
| def compute_ngrams(self,word, n=3): | |
| ''' | |
| Given a word of length N, this fucntion will compute N-(n-1) n-grams | |
| A trigram(n=3) is three letters ex: given 'that', we have 4-2=2 trigrams: | |
| 'tha' and 'hat' |
This file contains hidden or 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
| import java.util.LinkedList; | |
| /** | |
| * User: mattosaurus | |
| * Date: 1/30/12 | |
| * Time: 8:10 PM | |
| */ | |
| public class Queens { | |
| private int n; | |
| private LinkedList<Integer> state; |
This file contains hidden or 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
| import java.util.LinkedList; | |
| /** | |
| * User: mattosaurus | |
| * Date: 1/30/12 | |
| * Time: 8:10 PM | |
| */ | |
| public class Queens { | |
| private int n; | |
| private LinkedList<Integer> state; |
This file contains hidden or 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 recursive one works | |
| (define (prod term a next b) | |
| (if (> a b) | |
| 1 | |
| (* (term a) | |
| (prod term (next a) next b)))) | |
| ;;this iterative one does not | |
| ;;Ex1.31 | |
| ;;iterative product procedure |
This file contains hidden or 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
| (define (list?? maybe-list) | |
| (cond ((null? maybe-list) #t) | |
| ((and (pair? maybe-list) | |
| (list?? (cdr maybe-list))) #t) | |
| (else #f))) | |
| ;;recursive | |
| (define (list-len list) | |
| (if (null? list) | |
| 0 |
This file contains hidden or 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
| public class Problem { | |
| public static void main(String[] args) throws Exception { | |
| Scanner in = new Scanner(new File("voting.in")); | |
| String s = in.nextLine(); | |
| while (!s.equals("#")) { | |
| //etc | |
| } | |
| } | |
| } |