summaryrefslogtreecommitdiff
path: root/python/problems/functions
diff options
context:
space:
mode:
Diffstat (limited to 'python/problems/functions')
-rw-r--r--python/problems/functions/assign_numbers/common.py8
-rw-r--r--python/problems/functions/body_mass_index/common.py8
-rw-r--r--python/problems/functions/body_mass_index_2/common.py8
-rw-r--r--python/problems/functions/divisors/common.py8
-rw-r--r--python/problems/functions/divisors_sum/common.py8
-rw-r--r--python/problems/functions/friendly_numbers/common.py8
-rw-r--r--python/problems/functions/greatest/common.py8
-rw-r--r--python/problems/functions/greatest_absolutist/common.py8
-rw-r--r--python/problems/functions/greatest_negative/common.py8
-rw-r--r--python/problems/functions/palindrome/common.py8
-rw-r--r--python/problems/functions/palindromic_numbers/common.py8
-rw-r--r--python/problems/functions/perfect_numbers/common.py8
-rw-r--r--python/problems/functions/prime_numbers/common.py8
13 files changed, 52 insertions, 52 deletions
diff --git a/python/problems/functions/assign_numbers/common.py b/python/problems/functions/assign_numbers/common.py
index a997d2c..a1906b5 100644
--- a/python/problems/functions/assign_numbers/common.py
+++ b/python/problems/functions/assign_numbers/common.py
@@ -19,7 +19,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'numbers'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -34,7 +34,7 @@ def test(python, code):
test_in = [(func_name+'(%s)'%str(l[0]), None) for l in in_out]
test_out = [l[1] for l in in_out]
- 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)):
@@ -51,11 +51,11 @@ def test(python, code):
hints.append({'id': 'final_hint'})
return passed, hints
-def hint(python, code):
+def hint(python, code, aux_code=''):
tokens = get_tokens(code)
# run one test first to see if there are any exceptions
- answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ answer = python(code=aux_code+code, inputs=[(None, None)], timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc: return exc
diff --git a/python/problems/functions/body_mass_index/common.py b/python/problems/functions/body_mass_index/common.py
index 4331e06..8ebf7cd 100644
--- a/python/problems/functions/body_mass_index/common.py
+++ b/python/problems/functions/body_mass_index/common.py
@@ -19,7 +19,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'bmi'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -36,7 +36,7 @@ def test(python, code):
test_in = [(func_name+'(%s)'%str(l[0]), None) for l in in_out]
test_out = [l[1] for l in in_out]
- 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,11 +65,11 @@ def test(python, code):
hints.append({'id': 'final_hint'})
return passed, hints
-def hint(python, code):
+def hint(python, code, aux_code=''):
tokens = get_tokens(code)
# run one test first to see if there are any exceptions
- answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ answer = python(code=aux_code+code, inputs=[(None, None)], timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc: return exc
diff --git a/python/problems/functions/body_mass_index_2/common.py b/python/problems/functions/body_mass_index_2/common.py
index f4e2426..b02880d 100644
--- a/python/problems/functions/body_mass_index_2/common.py
+++ b/python/problems/functions/body_mass_index_2/common.py
@@ -19,7 +19,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'bmi2'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -36,7 +36,7 @@ def test(python, code):
test_in = [(func_name+'(*%s)'%str(l[0]), None) for l in in_out]
test_out = [l[1] for l in in_out]
- 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)):
@@ -64,11 +64,11 @@ def test(python, code):
hints.append({'id': 'final_hint'})
return passed, hints
-def hint(python, code):
+def hint(python, code, aux_code=''):
tokens = get_tokens(code)
# run one test first to see if there are any exceptions
- answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ answer = python(code=aux_code+code, inputs=[(None, None)], timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc: return exc
diff --git a/python/problems/functions/divisors/common.py b/python/problems/functions/divisors/common.py
index 6ba85fd..5b4f622 100644
--- a/python/problems/functions/divisors/common.py
+++ b/python/problems/functions/divisors/common.py
@@ -18,7 +18,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'divisors'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -37,7 +37,7 @@ def test(python, code):
test_in = [(func_name+'(%s)'%str(l[0]), None) for l in in_out]
test_out = [l[1] for l in in_out]
- 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)):
@@ -56,11 +56,11 @@ def test(python, code):
hints.append({'id': 'final_hint'})
return passed, hints
-def hint(python, code):
+def hint(python, code, aux_code=''):
tokens = get_tokens(code)
# run one test first to see if there are any exceptions
- answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ answer = python(code=aux_code+code, inputs=[(None, None)], timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc: return exc
diff --git a/python/problems/functions/divisors_sum/common.py b/python/problems/functions/divisors_sum/common.py
index e76ee38..219626c 100644
--- a/python/problems/functions/divisors_sum/common.py
+++ b/python/problems/functions/divisors_sum/common.py
@@ -20,7 +20,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'divisors_sum'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -39,7 +39,7 @@ def test(python, code):
test_in = [(func_name+'(%s)'%str(l[0]), None) for l in in_out]
test_out = [l[1] for l in in_out]
- 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)):
@@ -56,11 +56,11 @@ def test(python, code):
hints.append({'id': 'final_hint'})
return passed, hints
-def hint(python, code):
+def hint(python, code, aux_code=''):
tokens = get_tokens(code)
# run one test first to see if there are any exceptions
- answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ answer = python(code=aux_code+code, inputs=[(None, None)], timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc: return exc
diff --git a/python/problems/functions/friendly_numbers/common.py b/python/problems/functions/friendly_numbers/common.py
index 5c7e11b..4585055 100644
--- a/python/problems/functions/friendly_numbers/common.py
+++ b/python/problems/functions/friendly_numbers/common.py
@@ -25,7 +25,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'amicable_number'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -45,7 +45,7 @@ def test(python, code):
test_in = [(func_name+'(%s)'%str(l[0]), None) for l in in_out]
test_out = [l[1] for l in in_out]
- 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)):
@@ -62,11 +62,11 @@ def test(python, code):
hints.append({'id': 'final_hint'})
return passed, hints
-def hint(python, code):
+def hint(python, code, aux_code=''):
tokens = get_tokens(code)
# run one test first to see if there are any exceptions
- answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ answer = python(code=aux_code+code, inputs=[(None, None)], timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc: return exc
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
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
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
diff --git a/python/problems/functions/palindrome/common.py b/python/problems/functions/palindrome/common.py
index 0acdd20..0a41ab5 100644
--- a/python/problems/functions/palindrome/common.py
+++ b/python/problems/functions/palindrome/common.py
@@ -16,7 +16,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'palindrome'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -38,7 +38,7 @@ def test(python, code):
test_in = [(func_name+'("%s")'%str(l[0]), None) for l in in_out]
test_out = [l[1] for l in in_out]
- 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)):
@@ -55,11 +55,11 @@ def test(python, code):
hints.append({'id': 'final_hint'})
return passed, hints
-def hint(python, code):
+def hint(python, code, aux_code=''):
tokens = get_tokens(code)
# run one test first to see if there are any exceptions
- answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ answer = python(code=aux_code+code, inputs=[(None, None)], timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc: return exc
diff --git a/python/problems/functions/palindromic_numbers/common.py b/python/problems/functions/palindromic_numbers/common.py
index ec12df9..494e2d0 100644
--- a/python/problems/functions/palindromic_numbers/common.py
+++ b/python/problems/functions/palindromic_numbers/common.py
@@ -21,7 +21,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'numbers'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -40,7 +40,7 @@ def test(python, code):
test_in = [(func_name+'(%s)'%str(l[0]), None) for l in in_out]
test_out = [l[1] for l in in_out]
- 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)):
@@ -57,11 +57,11 @@ def test(python, code):
hints.append({'id': 'final_hint'})
return passed, hints
-def hint(python, code):
+def hint(python, code, aux_code=''):
tokens = get_tokens(code)
# run one test first to see if there are any exceptions
- answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ answer = python(code=aux_code+code, inputs=[(None, None)], timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc: return exc
diff --git a/python/problems/functions/perfect_numbers/common.py b/python/problems/functions/perfect_numbers/common.py
index e93cd03..b17daf0 100644
--- a/python/problems/functions/perfect_numbers/common.py
+++ b/python/problems/functions/perfect_numbers/common.py
@@ -23,7 +23,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'perfect'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -41,7 +41,7 @@ def test(python, code):
test_in = [(func_name+'(%s)'%str(l[0]), None) for l in in_out]
test_out = [l[1] for l in in_out]
- 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)):
@@ -58,11 +58,11 @@ def test(python, code):
hints.append({'id': 'final_hint'})
return passed, hints
-def hint(python, code):
+def hint(python, code, aux_code=''):
tokens = get_tokens(code)
# run one test first to see if there are any exceptions
- answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ answer = python(code=aux_code+code, inputs=[(None, None)], timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc: return exc
diff --git a/python/problems/functions/prime_numbers/common.py b/python/problems/functions/prime_numbers/common.py
index 0f53eba..aff24e9 100644
--- a/python/problems/functions/prime_numbers/common.py
+++ b/python/problems/functions/prime_numbers/common.py
@@ -21,7 +21,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'prime'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -36,7 +36,7 @@ def test(python, code):
test_in = [(func_name+'(%s)'%str(l[0]), None) for l in in_out]
test_out = [l[1] for l in in_out]
- 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)):
@@ -56,11 +56,11 @@ def test(python, code):
hints.append({'id': 'final_hint'})
return passed, hints
-def hint(python, code):
+def hint(python, code, aux_code=''):
tokens = get_tokens(code)
# run one test first to see if there are any exceptions
- answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ answer = python(code=aux_code+code, inputs=[(None, None)], timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc: return exc