assert total == n
assert collections[0] == collections[1]
+def gcd_dissector(n,m):
+ gcd = fractions.gcd(n,m)
+ return [[(m, (gcd,) * (n/gcd))],
+ [(n, (gcd,) * (m/gcd))]]
+
+def invent_dissection(n,m):
+ # Try to come up with a dissection by assorted simple methods.
+ best = 0
+ for dissector, this_reason in [
+ (gcd_dissector, "trivial gcd solution"),
+ ]:
+ dissection = dissector(n, m)
+ if dissection is None: continue
+ verify(n, m, dissection)
+ this_best = find_min_frag(dissection)
+ if best < this_best:
+ best, best_reason = this_best, this_reason
+ assert best > 0
+ return dissection, this_reason
+
def read(n,m):
best = 0
best = this_best
best_nature = nature
+ if best == 0:
+ # We don't have a stored solution at all, so make up something
+ # plausible if we can.
+ dissection, best_nature = invent_dissection(n, m)
+ best = find_min_frag(dissection)
+ dissections[(n,m)] = dissection
+
bound, bound_type = bounds.upper_bound(n, m)
if best == bound:
sys.stdout.write("</td>\n")
def main(args):
- limit = 18 # FIXME: configurable
+ limit = 24 # FIXME: configurable
sys.stdout.write("""\
<html>
<head>