Skip to content

Instantly share code, notes, and snippets.

@joostrijneveld
joostrijneveld / homer.py
Created October 30, 2014 12:07
Homer Simpson using Turtle graphics, transcribed from http://youtu.be/UnLz7CaBSFU
from turtle import *
def Homer():
tShirt()
mouth()
rightEye()
face()
eyePositioning()
leftEye()
ear()
@joostrijneveld
joostrijneveld / triangles.py
Created October 21, 2014 12:39
This file contains the solution to Problem 67 of Project Euler
#! /usr/bin/env python
with open('p067_triangle.txt') as f:
triangle = [[int(y) for y in x.strip().split(' ')] for x in f.readlines()]
upsidedown = list(reversed(triangle))
rowpairs = zip(upsidedown, upsidedown[1:])
for bot, top in rowpairs:
for i, x in enumerate(top):
top[i] = x + max(bot[i], bot[i+1])
print(triangle[0][0])
@joostrijneveld
joostrijneveld / risk.py
Last active August 29, 2015 14:06
Computes if/when it makes sense for the defending player in Risk to choose to throw only one die (if allowed).
#! /usr/bin/env python
def printmatrix(matrix):
""" source:
http://stackoverflow.com/questions/13214809/pretty-print-2d-python-list """
s = [[str(e) for e in row] for row in [['['+str(n)+']' for n in range(1, 7)]]+matrix]
lens = [len(max(col, key=len)) for col in zip(*s)]
fmt = '\t'.join('{{:{}}}'.format(x) for x in lens)
table = ['['+str(n)+"]\t"+fmt.format(*row) for (row, n) in zip(s, range(0, len(s)+1))]
@joostrijneveld
joostrijneveld / .gitignore
Created March 27, 2014 10:23 — forked from kogakure/.gitignore
.gitignore for LaTeX files including *.pdf
*.acn
*.acr
*.alg
*.aux
*.bbl
*.blg
*.dvi
*.glg
*.glo
*.gls

Keybase proof

I hereby claim:

  • I am joostrijneveld on github.
  • I am joostrijneveld (https://keybase.io/joostrijneveld) on keybase.
  • I have a public key whose fingerprint is 5336 27EA 8A21 A2B8 0260 E542 A4FE 39CF 49CB C553

To claim this, I am signing this object: