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
;; This is the missionaries & cannibals problem solved in Scheme. | |
;; The code is not as elegant as it could have been | |
;; (lacking recursion, in the spirit of Scheme, in many places). | |
;; It is also not very generic. Also does no optimization and | |
;; will apply search paths back and forth. | |
;; It works however, and should be relatively readable. | |
;; "https://class.coursera.org/aiplan-001/forum/thread?thread_id=164" | |
(use srfi-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
/** | |
* The first commented line is your dabblet’s title | |
*/ | |
background: #f06; | |
background: linear-gradient(45deg, #f06, yellow); | |
min-height: 100%; |
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 first commented line is your dabblet’s title | |
*/ | |
background: #f06; | |
background: linear-gradient(45deg, #f06, yellow); | |
min-height: 100%; |
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
This is the client code accessing the Sina weibo |
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
http://inventwithpython.com/pygame/chapter3.html |
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
# Reversi | |
# This is a Reversi game from http://inventwithpython.com/chapter15.html, I have revised it so you can run it under python 2.7. | |
# Enjoy it | |
import random | |
import sys | |
def drawBoard(board): | |
# This function prints out the board that it was passed. Returns None. | |
HLINE = ' +---+---+---+---+---+---+---+---+' |
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 | |
def getSecretNum(numDigits): | |
# Returns a string that is numDigits long, made up of unique random digits. | |
numbers = list(range(10)) | |
random.shuffle(numbers) | |
secretNum = '' | |
for i in range(numDigits): | |
secretNum += str(numbers[i]) | |
return secretNum |
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
# Tic Tac Toe | |
import random | |
def drawBoard(board): | |
# This function prints out the board that it was passed. | |
# "board" is a list of 10 strings representing the board (ignore index 0) | |
print(' | |') | |
print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9]) |
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 | |
HANGMANPICS = [''' | |
+---+ | |
| | | |
| | |
| | |
| | |
| | |
=========''', ''' |
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 PermutationEnumerator(items, n=None): | |
if n is None: | |
n = len(items) | |
for i in range(len(items)): | |
v = items[i:i+1] | |
if n == 1: | |
yield v | |
else: | |
rest = items[:i] + items[i+1:] | |
for p in PermutationEnumerator(rest, n-1): |
NewerOlder