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
import datetime | |
import itertools | |
import os | |
import pathlib | |
import smtplib | |
FIFTEEN_MINUTES = datetime.timedelta(minutes=15) | |
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
{ | |
"room_one": [ | |
"You are in a deep, dark forest. You have wandered off the trail, and have lost your way.", | |
"A column of chimney smoke appears over the treetops in the failing light. What do you do?" | |
], | |
"cottage": [ | |
"You enter the cottage. A table as tall as you stand in the center of the giant room,", | |
"and whole timbers burn in a cavernous fireplace. A cow on a spit roasts in the flames.", | |
"The room fills with the smell of perfectly done roast beef. Thundering footsteps", | |
"come closer and closer until a giant appears in the doorway be" |
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
import random | |
import json | |
CONTENT_PATH = './content.json' | |
DEBUG = True | |
#raw_input = input # Hack for Python 3 | |
class Scene(object): |
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
from math import sqrt | |
def count(start, step): | |
"""Happens to be included in the standard library""" | |
number = int(start) | |
while True: | |
yield number | |
start += number |
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 increment_result(func): | |
def wrapper(*args, **kwargs): | |
return func(*args, **kwargs) + 1 | |
return wrapper | |
@increment_result | |
def square_it(number): | |
return number * number |
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
"""The grid representing the Sleuth game board | |
Each cell in the two dimensional list represents a tile in the game. There are | |
three types of tiles that exist: inaccessable, normal, and door tiles. Tiles | |
are traversed only in the four cardinal directions (N, S, E, W). As such, | |
there exist two types of doors, North/South and East/West doors. The numbers | |
representing these tiles are defined as follows: | |
0 : Inaccessable Tile | |
1 : Normal Tile |
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
# I removed the big tag up top for now. Feel free to add it if you like | |
# Also removed the '#!/bin/python' bit as this script will never be run | |
# The namedtuple will be used for handling locations | |
from collections import namedtuple | |
# I moved the grid to a separate file because it cluttered up this one. | |
# Might as well keep the ugly contained, ya know? | |
from grid import 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
import random | |
from collections import namedtuple | |
COUNTRIES = ("Norway", "Sweden", "Germany", "Egypt", "South Africa", "Canada", | |
"China", "Brazil", "Mexico") | |
# Normally, I'd store key/value pairs as a dictionary for the next two globals, | |
# but in this case, it wouldn't help since we don't do any lookups. | |
CONDITIONS = (("Cancer", 30), ("AIDS", 40), ("Common Cold", 3), | |
("Healthy", 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 Foo(): | |
# It has an attribute called "class_attribute" | |
# All instances of 'Foo' will share (have a reference to) this class_attribute | |
# We are not in a method, so we have no reference to any instances, only the class | |
class_attribute = None | |
# This is the special method used when instantiating 'Foo' | |
# Here, 'self' has a special meaning ONLY because of the way it is called. | |
# As the first parameter, it will be given the created instance of 'Foo' | |
# Realize that the word 'self' has no special meaning. It is simply a parameter. |
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
numbers = ("73167176531330624919225119674426574742355349194934" | |
"96983520312774506326239578318016984801869478851843" | |
"85861560789112949495459501737958331952853208805511" | |
"12540698747158523863050715693290963295227443043557" | |
"66896648950445244523161731856403098711121722383113" | |
"62229893423380308135336276614282806444486645238749" | |
"30358907296290491560440772390713810515859307960866" | |
"70172427121883998797908792274921901699720888093776" | |
"65727333001053367881220235421809751254540594752243" | |
"52584907711670556013604839586446706324415722155397" |
NewerOlder