diff options
author | Michael Stone <michael@laptop.org> | 2011-01-07 23:18:45 (GMT) |
---|---|---|
committer | Michael Stone <michael@laptop.org> | 2011-01-08 01:18:29 (GMT) |
commit | e5ef28d21d6f607f07d21ff6ecd18fdc9b849a5c (patch) | |
tree | 73f7271ad823f877bb8870fbd1286cbc5699bc2a | |
parent | c28330741fd88f4afb5ba82bc92b2615b8dd4eef (diff) |
Add a modular addition puzzle.
Thereby demonstrating the ease and comfort of the new puzzle definition
system...
-rw-r--r-- | puzzles/90_modular_addition.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/puzzles/90_modular_addition.py b/puzzles/90_modular_addition.py new file mode 100644 index 0000000..f133d31 --- /dev/null +++ b/puzzles/90_modular_addition.py @@ -0,0 +1,9 @@ +name = "Modular Addition" + +def get_problem(self, difficulty): + x = self.generate_number(difficulty) + y = self.generate_number(difficulty) + y = abs(y) + 1 + question = "%s %% %s" % (x, y) + answer = x % y + return question, answer |