#!/usr/bin/env python
-import sys, subprocess, math
+import sys, subprocess, math, getopt
from fractions import Fraction
+verbose = False
def vprint(*args):
# In verbose mode, print diagnostics.
- pass # FIXME: implement verbose mode
+ if verbose:
+ sys.stdout.write(" ".join(map(str,args)) + "\n")
def find_partitions(n, minfrag, maxfrag=None, prefix=(), ret=None):
"""Find all partitions of n into integer pieces at least minfrag.
print " %d x (%s)" % (count, " + ".join([str(Fraction(k,d)) for k in col]))
def main():
- m, n = sorted(map(int,sys.argv[1:3]))
+ global verbose
+ opts, args = getopt.gnu_getopt(sys.argv[1:], "v")
+ for opt, val in opts:
+ if opt == "-v":
+ verbose = True
+ else:
+ assert False, "unrecognised option '%s'" % opt
+ m, n = sorted(map(int,args[:2]))
search_and_report(n, m)
if __name__ == "__main__":