@@ -168,7 +168,7 @@ def run(ui, settings):
168168 state = State .load ()
169169 limit = settings .limit
170170 while limit is None or limit > 0 :
171- problem = state .generate_problem ()
171+ problem = state .generate_problem (ui . answer_count () )
172172 ui .solve_problem (problem , state )
173173 state .update_from (problem )
174174 if not problem .answered_correctly ():
@@ -241,12 +241,12 @@ def save(self):
241241 pickle .dump (self ._correct_count , state_file , protocol = - 1 )
242242 pickle .dump (self ._error_count , state_file , protocol = - 1 )
243243
244- def generate_problem (self ):
244+ def generate_problem (self , answer_count ):
245245 repetitions = (itertools .repeat (e [0 ], int (e [1 ])) for e in self ._frequency_map .items () if e [0 ] != self ._last_generated )
246246 questions = list (i for i in (itertools .chain (* repetitions )))
247247 generated = random .choice (questions )
248248 self ._last_generated = generated
249- return Problem (* generated )
249+ return Problem (* generated , answer_count )
250250
251251 def dump (self ):
252252 print ('Frequency map:' )
@@ -282,6 +282,8 @@ def solve_problem(self, problem, state):
282282 def provide_feedback (self , problem , state ):
283283 print (":-)" if problem .answered_correctly () else ":-(" )
284284
285+ def answer_count (self ):
286+ return 4
285287
286288class GUI :
287289 _background_color = pygame .Color ('white' )
@@ -324,6 +326,9 @@ def __exit__(self, *exc):
324326 def _tick (self ):
325327 self ._clock .tick (30 ) # low framerate is fine for this app
326328
329+ def answer_count (self ):
330+ return 4
331+
327332 def solve_problem (self , problem , state ):
328333 answers = self ._display_problem (problem , state )
329334
@@ -437,10 +442,11 @@ def _answer_color(self, problem, answer, reveal_solution=False):
437442
438443class Problem :
439444
440- def __init__ (self , a , b ):
445+ def __init__ (self , a , b , answer_count ):
441446 self ._a = a
442447 self ._b = b
443- self ._answers = list (random .sample (sorted (self .wrong_answers ()), 3 )) + [self .correct_answer ()]
448+ wrong_answer_count = answer_count - 1
449+ self ._answers = list (random .sample (sorted (self .wrong_answers ()), wrong_answer_count )) + [self .correct_answer ()]
444450 random .shuffle (self ._answers )
445451
446452 def __str__ (self ):
0 commit comments