box-o-sand/mathpractice/sheet.py

17 lines
527 B
Python

import random
class Sheet(object):
def __init__(self, seed=None, entries=()):
self.seed = seed
self.entries = entries
@classmethod
def generate(cls, lowest_factor, highest_factor, total=100, seed=None):
entries = []
for f0 in range(lowest_factor, highest_factor):
for f1 in range(lowest_factor, highest_factor):
entries.append(((f0, f1), f0 * f1))
random.seed(seed)
random.shuffle(entries)
return cls(seed=seed, entries=entries)