Skip to content

Instantly share code, notes, and snippets.

Created November 1, 2011 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1330649 to your computer and use it in GitHub Desktop.
Save anonymous/1330649 to your computer and use it in GitHub Desktop.
import random
rows = 73
cols = 726
hdr = ""
for i in range(rows):
of = open("row%02d.cpp" % i,"w")
of.write('#include "rows.hpp"\n')
h = "const signed char row%02d[%d]" % (i,cols);
of.write( "%s = {" % h )
hdr += "extern %s;\n" % h
for j in range(cols):
if j % 22 == 0:
of.write("\n ")
of.write(" %4d," % random.randint(-128, 127))
of.write("\n};\n")
of.close()
of = open("rows.hpp","w")
#of.write("extern const signed char *table[%d];\n\n" % rows)
of.write(hdr);
of.close()
of = open("table.cpp","w")
of.write('#include "rows.hpp"\n')
of.write("const signed char * const table[%d] = {" % rows);
for i in range(rows):
if i % 10 == 0:
of.write("\n ");
of.write(" row%02d," % i)
of.write("\n};")
of.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment