Skip to content

Instantly share code, notes, and snippets.

@jfhbrook
Created March 1, 2010 05:53
Show Gist options
  • Save jfhbrook/318113 to your computer and use it in GitHub Desktop.
Save jfhbrook/318113 to your computer and use it in GitHub Desktop.
import random
'''
generates a pdf with a bunch of randomized bingo cards using entries from bingo.txt
Having issues getting formatting to work exactly how I want, though,
and, of course, it'd be a lot more useful if it could run on windows without
depending on latex and tikz and everything else... >_<
making it a webapp would be nice, but that sounds like a lot of work. :P
'''
gamestream = open('bingo.txt', 'r')
gametitle=gamestream.readline()
events=gamestream.readlines()
pages=5 ## pages to print
print r'\documentclass[10pt, letterpaper]{article}'
print r'\usepackage{tikz}'
print r'\usepackage{fullpage}'
print r'\begin{document}'
print r'\pagestyle{empty}'
print r'\begin{center}'
for i in range(pages):
random.shuffle(events)
fields=events[0:12]+[r'YOU\\ SHOWED\\ UP']+events[12:24]
print r'\Huge %(title)s \normalsize' % {'title': gametitle}
print r''
print r'\bigskip'
print r''
print r'\begin{tikzpicture}'
print r'[bsquare/.style={rectangle,draw,minimum size=1.25in,text width=1.0in}]'
for x in xrange(5):
for y in xrange(5):
print '\\node [bsquare] at (%(x)2f in,%(y)2f in) {%(event)s };' % \
{'x':x*1.25,'y':y*1.25,'event': fields[5*x+y]}
print r'\end{tikzpicture}'
print ''
print r'\pagebreak'
print ''
print r'\end{center}'
print r'\end{document}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment