--- /dev/null
+#!/usr/bin/env python
+
+import sys, os, re, fractions
+from fractions import Fraction
+
+import bounds
+
+header_re = re.compile(r'^(\d+) into (\d+).*:.* ([\d/]+)')
+
+def read(n,m):
+ best = 0
+
+ # Look for appropriate file(s).
+ for filename, nature in [("data/main.%d.%d" % (n,m), "e"),
+ ("data/partition.%d.%d" % (n,m), "p"),
+ ("data/manual.%d.%d" % (n,m), "m")]:
+ if os.path.exists(filename):
+ with open(filename) as f:
+ header = f.readline()
+ match = header_re.match(header)
+ assert match is not None
+ assert int(match.group(1)) == n
+ assert int(match.group(2)) == m
+ this_best = Fraction(match.group(3))
+ if this_best > best:
+ best = this_best
+ best_nature = nature
+
+ bound, bound_type = bounds.upper_bound(n, m)
+
+ if best == bound:
+ tdclass = "known"
+ show_bound = ""
+ elif best_nature == 'e':
+ tdclass = "believed"
+ show_bound = ""
+ elif best_nature == 'p':
+ tdclass = "probable"
+ show_bound = " (– %s)"
+ else:
+ tdclass = "range"
+ show_bound = " – %s"
+ sys.stdout.write("<td class=\"%s\">" % tdclass)
+ sys.stdout.write(str(best))
+ if show_bound != "":
+ sys.stdout.write(show_bound % str(bound))
+ sys.stdout.write("</td>\n")
+
+def main(args):
+ limit = 18 # FIXME: configurable
+ sys.stdout.write("""\
+<html>
+<head>
+<title>Known bounds for stick-dissecting problem</title>
+<style type="text/css">
+table, td, th {
+ border: 1px solid black;
+ border-collapse: collapse;
+}
+td.known {
+ background-color: #00ff00;
+}
+td.believed {
+ background-color: #44ff44;
+}
+td.probable {
+ background-color: #88ff88;
+}
+td.range {
+ background-color: #ff8888;
+}
+</style>
+</head>
+<body>
+<table>
+""")
+ sys.stdout.write("<tr>\n")
+ sys.stdout.write("<th>n \\ m</th>\n")
+ for m in range(2,limit-1):
+ sys.stdout.write("<th>%d</th>\n" % m)
+ sys.stdout.write("</tr>\n")
+ for n in range(2,limit):
+ sys.stdout.write("<tr>\n")
+ sys.stdout.write("<th>%d</th>\n" % n)
+ for m in range(2,n):
+ read(n, m)
+ sys.stdout.write("</tr>\n")
+ sys.stdout.write("</table>\n")
+ sys.stdout.write("</body></html>\n")
+
+if __name__ == "__main__":
+ main(sys.argv[1:])