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
licence, itertools, board, vectors, get, put, coloured, board_string, winner = 'MIT', __import__('itertools'), [[] for _ in xrange(7)], [(0, 1), (1, 0), (1, 1), (1, -1)], lambda i, j: board[i][j] if 0 <= i < 7 and len(board[i]) > j >= 0 else ' ', lambda i, p: board[i].append(p) or True if 0 <= i < 7 and len(board[i]) < 6 else False, (lambda string, colour: {'red': '\033[1;31m{}\033[1;m', 'yellow': '\033[1;33m{}\033[1;m', 'blue': '\033[1;34m{}\033[1;m'}.get(colour, '{}').format(string)) if not __import__('os').getenv('NOCOLOR') else lambda string, colour: string, lambda: '\n'.join(coloured(' | ', 'blue') + coloured(' | ', 'blue').join(get(column, row) for column in range(7)) + coloured(' | ', 'blue') for row in range(5, -1, -1)) + '\n' + coloured(' | ', 'blue') + coloured(' | ', 'blue').join(coloured('{}', 'blue').format(i + 1) for i in range(7)) + coloured(' | ', 'blue'), lambda: any(all(get(i, j) != ' ' and get(i, j) == get(i + vi * step, j + vj * step) for step in range(4)) for vi, vj in vectors for j in ra |
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
c,g,s,m,l,p=''.join(x for x in __import__('random').choice(list(open('/usr/share/dict/words'))).upper() if x.isalpha()),set(),'|===\n| |\n|{3} {0} {5}\n| {2}{1}{4}\n| {6} {7}\n| {8} {9}'.format,list(r'QT-\-//\||'),10,' ' | |
while not all(q in g for q in c) and l:_,l=[g.add(x) for x in raw_input('%s %s left\n%s\n%s:'%(p.join(sorted(g)),l,s(*(m[:-l]+[p]*l)),p.join(q if q in g else '_' for q in c))).upper() if x.isalpha()],max(10-len(g-set(c)),0) | |
print 'You',['win!','lose!\n'+s(*m)][not l],'\nWord was',c |
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
license, chosen_word, guesses, scaffold, man, guesses_left = 'https://opensource.org/licenses/MIT', ''.join(filter(str.isalpha, __import__('random').choice(open('/usr/share/dict/words').readlines()).upper())), set(), '|======\n| |\n| {3} {0} {5}\n| {2}{1}{4}\n| {6} {7}\n| {8} {9}\n|', list('OT-\\-//\\||'), 10 | |
while not all(letter in guesses for letter in chosen_word) and guesses_left: _, guesses_left = map(guesses.add, filter(str.isalpha, raw_input('%s(%s guesses left)\n%s\n%s:' % (','.join(sorted(guesses)), guesses_left, scaffold.format(*(man[:10-guesses_left] + [' '] * guesses_left)), ' '.join(letter if letter in guesses else '_' for letter in chosen_word))).upper())), max((10 - len(guesses - set(chosen_word))), 0) | |
print 'You', ['lose!\n' + scaffold.format(*man), 'win!'][bool(guesses_left)], '\nWord was', chosen_word |
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 have tried to fork-bomb myself in the past. | |
ulimit -u 1000 | |
export ANDROID_HOME=/usr/local/android/sdk | |
export PATH=$PATH:/usr/local/go/bin:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools | |
alias set_gopath='export GOPATH=$(pwd)' | |
export EDITOR=emacs | |
export GOPATH=~/projects/go | |
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
-- Standard awesome library | |
require("awful") | |
require("awful.autofocus") | |
require("awful.rules") | |
-- Theme handling library | |
require("beautiful") | |
-- Notification library | |
require("naughty") | |
-- Load Debian menu entries |
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
(when (load "flymake" t) | |
(defun flymake-pyflakes-init () | |
(let* ((temp-file (flymake-init-create-temp-buffer-copy | |
'flymake-create-temp-inplace)) | |
(local-file (file-relative-name | |
temp-file | |
(file-name-directory buffer-file-name)))) | |
(list "pyflakes" (list local-file)))) | |
(add-to-list 'flymake-allowed-file-name-masks |
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
'''Expressing "Find the winner in connect 4" as a dynamic programming | |
problem. | |
''' | |
import json | |
lines = [] | |
while True: | |
try: | |
lines.append(raw_input()) | |
except EOFError: |
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 setuptools import setup, find_packages | |
setup( | |
name = 'Undefined', | |
version = '0.0.0', | |
author = 'Danver Braganza', | |
author_email = '[email protected]', | |
description = ('A description of my project goes here.'), | |
license = 'WTFPL', | |
# keywords = 'space separated', |
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
[tox] | |
envlist=py27,lint | |
[testenv] | |
downloadcache={homedir}/.pipcache | |
distribute=True | |
sitepackages=False | |
[testenv:py27] | |
deps=nose |