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 itertools | |
values = "34567890JQKA2" | |
def cardRanker(card): | |
return values.index(card[0]), card | |
def sort_cards(hand): | |
return [c[1] for c in sorted(map(cardRanker,hand))] | |
def isStraight(play): |
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 print_board(): | |
for i in range(0,3): | |
for j in range(0,3): | |
print map[2-i][austin], | |
if austin != 2: | |
print "|", | |
print "" | |
def check_done(): |
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 Song(object): | |
def __init__(self, lyrics): | |
self.lyrics = lyrics | |
def sing_me_a_song(self): | |
for line in self.lyrics: | |
print line | |
pop_it = Song(["Pop it", |
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 sys import exit | |
from random import randint | |
class Scene(object): | |
def enter(self): | |
print "This scene is not yet configured. Subclass it and implement enter()." | |
exit(1) | |
class Engine(object): |
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
i = 0 | |
numbers = [] | |
while i < 6: | |
print "At the top i is %d" % i | |
numbers.append(i) | |
print "Numbers now: ", numbers | |
print "At the bottom i is %d" % i |
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
i = 0 | |
numbers = [] | |
while i < 6: | |
print "At the top i is %d" % i | |
numbers.append(i) | |
i = i + 1 | |
print "Numbers now: ", numbers | |
print "At the bottom i is %d" % i |
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
scenes = [ | |
["""Welcome to trailz, an interactive text game. The rules are simple, you will be given a scenario, and can type whatever is in the parentheses. Good luck! | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
Help: to pick up and item, type "take" and that particular items name. To check your inventory, type "list items". | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
You are walking on a wooden trail and notice you are lost, and soon arrive at a crossroads right before huge trees fall across the path you have been walking on, so you may not turn back. Do you want to: (1) Go along the east path, (2) Go along the west path, or (3) Go along the north path.""", 5, 6, 7], | |
#This is the crossroads from the east: 1 | |
["You again arrive at the crossroads. Do you want to: (1) Go along the north path, or (2) Go along the west path.", 7, 6], | |
#this is from the west: 2 |
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
print "You enter a dark room with two doors. Do you go through door #1 or door #2?" | |
door = raw_input("> ") | |
if door == "1": | |
print "There's a giant bear here eating a cheese cake. What do you do?" | |
print "1. Take the cake." | |
print "2. Scream at the bear." | |
bear = raw_input("> ") |
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
print "This game only involes yes or no questions sometimes verbs, if it is special verb it will be higlighted like 'this'. Would you like to 'start'?" | |
start_game = raw_input(">") | |
if start_game == "start": | |
print "You are walking in the woods and see a small hole. Would you like to approach it?" | |
hole = raw_input("> ") | |
if hole == "yes": |
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
heads, legs = map(float, raw_input().split()) | |
chickens = legs/2 | |
cows = 0 | |
while heads < cows + chickens: | |
chickens -= 2 | |
cows += 1 | |
if cows*4 + chickens*2 == legs and cows + chickens == heads: | |
print "There are %d chickens and %d cows." % (chickens, cows) | |
else: |
NewerOlder