Skip to content

Instantly share code, notes, and snippets.

View spratt's full-sized avatar

Simon Pratt spratt

View GitHub Profile
(defun ttt-repl (board)
"Read-Eval-Print-Loop for Tic-Tac-Toe"
(ttt-print board)
(ttt-repl (ttt-eval (ttt-read board))))
(documentation 'ttt-repl 'function)
'(nil nil nil nil X nil nil nil O)
(defun ttt-print (board)
"Prints a tic-tac-toe board."
(let* ((nl (string #\Newline))
(str (concatenate 'string
"S|S|S" nl
"-|-|-" nl
"S|S|S" nl
"-|-|-" nl
"S|S|S" nl)))
(format t str)))
(defun ttt-print (board)
"Prints a tic-tac-toe board."
(let* ((symbol nil)
(nl (string #\Newline))
(str (concatenate 'string
"S|S|S" nl
"-|-|-" nl
"S|S|S" nl
"-|-|-" nl
"S|S|S" nl)))
(defun ttt-print (board)
"Pretty prints a given board."
(format t "~% 1 2 3 <- cols~%~%")
(format t "1 ~1<~@[~A~]~>|~1<~@[~A~]~>|~1<~@[~A~]~>~% -+-+-~%"
(pop board) (pop board) (pop board))
(format t "2 ~1<~@[~A~]~>|~1<~@[~A~]~>|~1<~@[~A~]~>~% -+-+-~%"
(pop board) (pop board) (pop board))
(format t "3 ~1<~@[~A~]~>|~1<~@[~A~]~>|~1<~@[~A~]~>~%"
(pop board) (pop board) (pop board))
(format t "^~% \\_ rows~%"))
for(var i = 0; i < objects.length; i++) {
build_element(objects[i]);
}
@spratt
spratt / rand.py
Created May 19, 2013 03:55
Randomly select 12 words from input words specified one word per line
#!/usr/bin/env python2.7
import random
from sys import stdin
words = []
for line in stdin:
words.append(line.strip())
print(random.sample(words,12))
@spratt
spratt / rand.py
Last active December 17, 2015 11:59
randomly select from lines of input
#!/usr/bin/env python2.7
import random
from sys import stdin, argv
words = []
for line in stdin:
words.append(line.strip())
n = int(argv[1])
@spratt
spratt / gist:5606662
Created May 19, 2013 04:15
list of movie genres
Aerospace film
Biography
Buddy Cop film
Burlesque film
Chick Flick
Circus film
Comedy film
Black comedy
Gross-out film
Romantic comedy film