summaryrefslogtreecommitdiff
path: root/python/problems/functions/greatest_negative/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/problems/functions/greatest_negative/common.py')
-rw-r--r--python/problems/functions/greatest_negative/common.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/python/problems/functions/greatest_negative/common.py b/python/problems/functions/greatest_negative/common.py
index 6b25e28..ea22cad 100644
--- a/python/problems/functions/greatest_negative/common.py
+++ b/python/problems/functions/greatest_negative/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_neg']):
return False, [{'id' : 'no_func_name', 'args' : {'func_name' : 'max_neg'}}]
@@ -52,7 +52,7 @@ def test(python, code):
test_in = [('max_neg(%s)'%str(l), None) for l in test_lists]
test_out = [None, -1, -2, None, -8, -8, -2, -1, -2, -1, None, -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)):
@@ -65,14 +65,14 @@ def test(python, code):
hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
return n_correct == len(test_in), hints
-def hint(python, code):
+def hint(python, code, aux_code=''):
tokens = get_tokens(code)
# having function max_neg is necessary!
if not has_token_sequence(tokens, ['max_neg']):
return [{'id' : 'no_func_name', 'args' : {'func_name' : 'max_neg'}}]
# run one test to see if there are any exceptions
- answer = python(code=code, inputs=[('max_neg([1, 3, -3, -6, 4, 3, 2])', None)], timeout=1.0)
+ answer = python(code=aux_code+code, inputs=[('max_neg([1, 3, -3, -6, 4, 3, 2])', None)], timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc: return exc