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 here. Read input from STDIN. Print output to STDOUT | |
import re | |
def read_corpus(): | |
corpus = {} | |
with open('corpus.txt') as c: | |
for line in c: | |
words = re.findall(r"[a-z]+",line.strip().lower()) | |
for word in words: | |
if word is '': | |
continue |
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 here. Read input from STDIN. Print output to STDOUT | |
class Node: | |
def __init__(self,state,action): | |
self.state = state | |
self.action = action | |
self.parent = None | |
self.H = 0 | |
self.G = 0 | |
def move_cost(self,other): | |
return 1 |
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 here. Read input from STDIN. Print output to STDOUT | |
def read_words(): | |
with open('words.txt') as f: | |
return [line.strip().lower() for line in f] | |
def strip_chars(word): | |
word = word.lower().strip() | |
if word.startswith('#'): | |
return word[1:] | |
if word.startswith('www'): |
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 here. Read input from STDIN. Print output to STDOUT | |
def read_words(): | |
with open('words.txt') as f: | |
return [line.strip().lower() for line in f] | |
def strip_chars(word): | |
word = word.lower().strip() | |
if word.startswith('#'): | |
return word[1:] | |
if word.startswith('www'): |
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 here. Read input from STDIN. Print output to STDOUT | |
class Node: | |
def __init__(self,value,point): | |
self.value = value | |
self.point = point | |
self.parent = None | |
self.H = 0 | |
self.G = 0 | |
def move_cost(self,other): | |
return 0 if self.value == '.' else 1 |
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
#!/usr/bin/python | |
# Head ends here | |
import heapq | |
class Node: | |
def __init__(self, point,parent=None): | |
self.point = point | |
self.parent = parent | |
def nextMove( x, y, pacman_x, pacman_y, food_x, food_y, grid): |
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
#!/usr/bin/python | |
# Head ends here | |
from collections import deque | |
class Node: | |
def __init__(self, point,parent=None): | |
self.point = point | |
self.parent = parent | |
explored = [] |
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
#!/usr/bin/python | |
#class Node: | |
# def __init__(self,point,parent=None): | |
# self.point = point | |
# self.parent = parent | |
# Head ends here | |
explored = [] | |
def nextMove( x, y, pacman_x, pacman_y, food_x, food_y, grid): |
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
#include <cmath> | |
#include <cstdio> | |
#include <vector> | |
#include <iostream> | |
#include <algorithm> | |
#include <map> | |
using namespace std; | |
int count(unsigned int u) | |
{ | |
unsigned int uCount; |
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
complement_memo = {} | |
def complement(ar): | |
a, b = ar | |
total = 0 | |
for i in xrange(a,b+1): | |
if not i in complement_memo: | |
complement_memo[i] = count(i) | |
total += complement_memo[i] | |
print total |