summaryrefslogtreecommitdiff
path: root/python/problems/functions/greatest/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/problems/functions/greatest/common.py')
-rw-r--r--python/problems/functions/greatest/common.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/python/problems/functions/greatest/common.py b/python/problems/functions/greatest/common.py
index 9d5401f..175cef6 100644
--- a/python/problems/functions/greatest/common.py
+++ b/python/problems/functions/greatest/common.py
@@ -28,7 +28,7 @@ hint_type = {
'return_indent': Hint('return_indent')
}
-def test(python, code):
+def test(python, code, aux_code=''):
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', 'max_val']):
return False, [{'id' : 'no_func_name', 'args' : {'func_name' : 'max_val'}}]
@@ -48,7 +48,7 @@ def test(python, code):
test_in = [('max_val(%s)'%str(l), None) for l in test_lists]
test_out = [6, 6, 6, 6, 6, 6, 0, -1, -1, -1, 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)):
@@ -63,14 +63,14 @@ def test(python, code):
hints.append({'id': 'final_hint'})
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_val']):
return [{'id' : 'no_func_name', 'args' : {'func_name' : 'max_val'}}]
# run one test first to see if there are any exceptions
- answer = python(code=code, inputs=[('max_val([1, 2, 3, 6, 4, 2, 5])', None)], timeout=1.0)
+ answer = python(code=aux_code+code, inputs=[('max_val([1, 2, 3, 6, 4, 2, 5])', None)], timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc: return exc