import os import random import sys def main(sysargs=sys.argv[:]): lowest_factor = 0 highest_factor = 15 total = 100 if '-h' in sysargs or '--help' in sysargs: return _help(sysargs=sysargs) if len(sysargs) > 1: lowest_factor = int(sysargs[1]) if len(sysargs) > 2: highest_factor = int(sysargs[2]) if len(sysargs) > 3: total = int(sysargs[3]) _mksheet(lowest_factor, highest_factor, total=total) return 0 def _mksheet(lowest_factor, highest_factor, out=sys.stdout, total=100): gen = [_format_header()] for f0, f1 in _generate_matrix(lowest_factor, highest_factor, total=total): gen.append(_format_pair(f0, f1)) gen.append(_format_footer()) out.write('\n'.join(gen)) out.write('\n') def _generate_matrix(lowest_factor, highest_factor, total=100): gen = [] for f0 in range(lowest_factor, highest_factor): for f1 in range(lowest_factor, highest_factor): gen.append((f0, f1)) random.shuffle(gen) return gen def _format_header(): return '\n'.join([ '', '', '
', '', '{}'.format(f0), '
', '', 'x', '{}'.format(f1), '
', '', '', '
', '