diff options
Diffstat (limited to 'python/problems/functions/greatest_absolutist')
-rw-r--r-- | python/problems/functions/greatest_absolutist/common.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/python/problems/functions/greatest_absolutist/common.py b/python/problems/functions/greatest_absolutist/common.py index 0d0eef4..e0582d1 100644 --- a/python/problems/functions/greatest_absolutist/common.py +++ b/python/problems/functions/greatest_absolutist/common.py @@ -31,7 +31,7 @@ hint_type = { } -def test(python, code): +def test(python, code, aux_code=''): tokens = get_tokens(code) if not has_token_sequence(tokens, ['def', 'max_abs']): return False, [{'id' : 'no_func_name', 'args' : {'func_name' : 'max_abs'}}] @@ -51,7 +51,7 @@ def test(python, code): test_in = [('max_abs(%s)'%str(l), None) for l in test_lists] test_out = [6, 6, 6, 6, -8, -8, 8, -6, -8, -8, 42, -42] - answers = python(code=code, inputs=test_in, timeout=1.0) + answers = python(code=aux_code+code, inputs=test_in, timeout=1.0) n_correct = 0 tin, tout = None, None for i, (ans, to) in enumerate(zip(answers, test_out)): @@ -69,14 +69,14 @@ def test(python, code): return n_correct == len(test_in), hints -def hint(python, code): +def hint(python, code, aux_code=''): tokens = get_tokens(code) # having function max_val is necessary! if not has_token_sequence(tokens, ['max_abs']): return [{'id' : 'no_func_name', 'args' : {'func_name' : 'max_abs'}}] # run one test first to see if there are any exceptions - answer = python(code=code, inputs=[('max_abs([1, 3, 3, -6, 4, 3, 2])', None)], timeout=1.0) + answer = python(code=aux_code+code, inputs=[('max_abs([1, 3, 3, -6, 4, 3, 2])', None)], timeout=1.0) exc = get_exception_desc(answer[0][3]) if exc: return exc |