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 random | |
| class Throw(object): | |
| choices = {1:'Rock',2:'Paper', 3:'Scissors'} | |
| victory = { | |
| (1,3):'Rock smashes Scissors', | |
| (2,1):'Paper covers Rock', | |
| (3,2):'Scissors cut Paper', | |
| } |
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
| from pprint import pprint | |
| import dicttoxml | |
| from xml.dom.minidom import parseString | |
| FILES = ['FILE2.COMPAS', 'FILE1.COMPAS'] |
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 os | |
| import sys | |
| import math | |
| import random | |
| import itertools | |
| import bisect | |
| # Fix Python 2.x. |
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
| from random import randrange, sample | |
| from collections import Counter | |
| class Map(object): | |
| water_chance = 10 #Chance of ground being water | |
| water_near_water = 30 #If a water tile is to our left or top | |
| house_chance = 5 | |
| boat_chance = 25 #If we're on a water tile, with a house nearby, chance of it being a boat | |
| def __init__(self, height, width): |
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
| from string import ascii_lowercase | |
| from pprint import pprint | |
| def init_matrix(): | |
| ''' | |
| check out collections.defaultdict for a much easier way to do this | |
| ''' | |
| matrix = {} | |
| for a in ascii_lowercase: | |
| matrix[a] = {} |
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
| from string import ascii_lowercase | |
| from collections import defaultdict | |
| from pprint import pprint | |
| def add_word(matrix, word): | |
| ''' | |
| this modifies a letter count matrix to add in the pairs | |
| the matrix stores things as follows: | |
| matrix[first][second] = count of times first+second appear in word |
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
| from string import ascii_lowercase | |
| from collections import defaultdict | |
| from itertools import zip_longest | |
| from pprint import pprint | |
| from random import random | |
| import bisect | |
| class Matrix(object): | |
| def __init__(self, words = None): |
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
| from copy import deepcopy | |
| from collections import defaultdict | |
| import random | |
| import time | |
| def load_dictionary(): | |
| with open('dictionary.txt', mode='r') as fh: | |
| result = [w.strip() for w in fh] | |
| return result |
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 | |
| import random | |
| #Helper dictionary to reverse directions | |
| # line is too long, break it up | |
| reverse_directions = { "north" : "south", | |
| "east":"west", | |
| "west":"east", | |
| "south":"north" } |
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 random | |
| from collections import defaultdict | |
| from pprint import pprint | |
| class City(object): | |
| def __init__(self, data=None): | |
| self.name = None | |
| self.neighbors = {} | |
| if data is not None: |