summaryrefslogtreecommitdiff
path: root/python/problems
diff options
context:
space:
mode:
Diffstat (limited to 'python/problems')
-rw-r--r--python/problems/comprehensions/inverse_morse/common.py8
-rw-r--r--python/problems/comprehensions/isbn/common.py8
-rw-r--r--python/problems/comprehensions/morse/common.py8
-rw-r--r--python/problems/comprehensions/std/common.py8
-rw-r--r--python/problems/comprehensions/subs/common.py8
-rw-r--r--python/problems/comprehensions/sumsquares/common.py8
-rw-r--r--python/problems/comprehensions/sumsquares_palindrome/common.py8
-rw-r--r--python/problems/dictionaries/children/common.py8
-rw-r--r--python/problems/dictionaries/family/common.py8
-rw-r--r--python/problems/dictionaries/following_words/common.py8
-rw-r--r--python/problems/dictionaries/freq_following_word/common.py8
-rw-r--r--python/problems/dictionaries/grandchildren/common.py8
-rw-r--r--python/problems/dictionaries/max_characters/common.py8
-rw-r--r--python/problems/dictionaries/most_frequent/common.py8
-rw-r--r--python/problems/dictionaries/show_letters/common.py8
-rw-r--r--python/problems/dictionaries/successors/common.py8
-rw-r--r--python/problems/dictionaries/text/common.py8
-rw-r--r--python/problems/dictionaries/transactions/common.py8
-rw-r--r--python/problems/dictionaries/waiter/common.py8
-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
-rw-r--r--python/problems/functions_and_modules/all/common.py8
-rw-r--r--python/problems/functions_and_modules/any/common.py8
-rw-r--r--python/problems/functions_and_modules/caesar_cipher/common.py8
-rw-r--r--python/problems/functions_and_modules/dominoes/common.py8
-rw-r--r--python/problems/functions_and_modules/largest_sublist/common.py8
-rw-r--r--python/problems/functions_and_modules/lists_sum/common.py8
-rw-r--r--python/problems/functions_and_modules/longest_word/common.py8
-rw-r--r--python/problems/functions_and_modules/map/common.py8
-rw-r--r--python/problems/functions_and_modules/multiplicative_range/common.py8
-rw-r--r--python/problems/functions_and_modules/similarity/common.py8
-rw-r--r--python/problems/functions_and_modules/suspicious_words/common.py8
-rw-r--r--python/problems/introduction/average/common.py8
-rw-r--r--python/problems/introduction/ballistics/common.py8
-rw-r--r--python/problems/introduction/fahrenheit_to_celsius/common.py8
-rw-r--r--python/problems/introduction/fast_fingers/common.py8
-rw-r--r--python/problems/introduction/fast_fingers_2/common.py8
-rw-r--r--python/problems/introduction/leap_year/common.py8
-rw-r--r--python/problems/introduction/pythagorean_theorem/common.py8
-rw-r--r--python/problems/lists_and_for/calculator_polish/common.py8
-rw-r--r--python/problems/lists_and_for/contains_42/common.py8
-rw-r--r--python/problems/lists_and_for/contains_multiples/common.py8
-rw-r--r--python/problems/lists_and_for/contains_string/common.py8
-rw-r--r--python/problems/lists_and_for/counting/common.py8
-rw-r--r--python/problems/lists_and_for/divisors/common.py8
-rw-r--r--python/problems/lists_and_for/divisors_sum/common.py8
-rw-r--r--python/problems/lists_and_for/every_third/common.py8
-rw-r--r--python/problems/lists_and_for/perfect_numbers/common.py8
-rw-r--r--python/problems/lists_and_for/places/common.py8
-rw-r--r--python/problems/lists_and_for/prefix/common.py8
-rw-r--r--python/problems/lists_and_for/split_word/common.py8
-rw-r--r--python/problems/lists_and_for/substrings/common.py8
-rw-r--r--python/problems/recursion/depth_to/common.py41
-rw-r--r--python/problems/recursion/family_tree_name/common.py42
-rw-r--r--python/problems/recursion/family_tree_name_list/common.py42
-rw-r--r--python/problems/recursion/family_tree_youngest/common.py41
-rw-r--r--python/problems/recursion/path_to/common.py42
-rw-r--r--python/problems/while_and_if/buy_five/common.py8
-rw-r--r--python/problems/while_and_if/checking_account/common.py8
-rw-r--r--python/problems/while_and_if/competition/common.py8
-rw-r--r--python/problems/while_and_if/consumers_anonymous/common.py8
-rw-r--r--python/problems/while_and_if/minimax/common.py8
-rw-r--r--python/problems/while_and_if/top_shop/common.py8
74 files changed, 300 insertions, 460 deletions
diff --git a/python/problems/comprehensions/inverse_morse/common.py b/python/problems/comprehensions/inverse_morse/common.py
index b7644b5..20488b9 100644
--- a/python/problems/comprehensions/inverse_morse/common.py
+++ b/python/problems/comprehensions/inverse_morse/common.py
@@ -60,7 +60,7 @@ hint_type = {
'has_loop': Hint('has_loop')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'morse2txt'
tokens = get_tokens(code)
ast = get_ast(code)
@@ -78,7 +78,7 @@ def test(python, code):
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)):
@@ -103,11 +103,11 @@ def test(python, code):
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/comprehensions/isbn/common.py b/python/problems/comprehensions/isbn/common.py
index 4724713..9de9580 100644
--- a/python/problems/comprehensions/isbn/common.py
+++ b/python/problems/comprehensions/isbn/common.py
@@ -19,7 +19,7 @@ hint_type = {
'has_loop': Hint('has_loop')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'valid'
tokens = get_tokens(code)
ast = get_ast(code)
@@ -40,7 +40,7 @@ def test(python, code):
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):
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/comprehensions/morse/common.py b/python/problems/comprehensions/morse/common.py
index 785862e..4b112cc 100644
--- a/python/problems/comprehensions/morse/common.py
+++ b/python/problems/comprehensions/morse/common.py
@@ -59,7 +59,7 @@ hint_type = {
'has_loop': Hint('has_loop')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'txt2morse'
tokens = get_tokens(code)
ast = get_ast(code)
@@ -77,7 +77,7 @@ def test(python, code):
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)):
@@ -102,11 +102,11 @@ def test(python, code):
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/comprehensions/std/common.py b/python/problems/comprehensions/std/common.py
index 05c7357..7ac0662 100644
--- a/python/problems/comprehensions/std/common.py
+++ b/python/problems/comprehensions/std/common.py
@@ -23,7 +23,7 @@ hint_type = {
'has_loop': Hint('has_loop')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'std'
tokens = get_tokens(code)
ast = get_ast(code)
@@ -42,7 +42,7 @@ def test(python, code):
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)):
@@ -67,11 +67,11 @@ def test(python, code):
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/comprehensions/subs/common.py b/python/problems/comprehensions/subs/common.py
index 6998998..d745578 100644
--- a/python/problems/comprehensions/subs/common.py
+++ b/python/problems/comprehensions/subs/common.py
@@ -19,7 +19,7 @@ hint_type = {
'has_loop': Hint('has_loop')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'subs'
tokens = get_tokens(code)
ast = get_ast(code)
@@ -36,7 +36,7 @@ def test(python, code):
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)):
@@ -61,11 +61,11 @@ def test(python, code):
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/comprehensions/sumsquares/common.py b/python/problems/comprehensions/sumsquares/common.py
index bda561e..cd23c9c 100644
--- a/python/problems/comprehensions/sumsquares/common.py
+++ b/python/problems/comprehensions/sumsquares/common.py
@@ -18,7 +18,7 @@ hint_type = {
'no_comprehension': Hint('no_comprehension')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'sumsquares'
tokens = get_tokens(code)
ast = get_ast(code)
@@ -34,7 +34,7 @@ def test(python, code):
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)):
@@ -59,11 +59,11 @@ def test(python, code):
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/comprehensions/sumsquares_palindrome/common.py b/python/problems/comprehensions/sumsquares_palindrome/common.py
index 9e66eb0..dcb565d 100644
--- a/python/problems/comprehensions/sumsquares_palindrome/common.py
+++ b/python/problems/comprehensions/sumsquares_palindrome/common.py
@@ -20,7 +20,7 @@ hint_type = {
'has_loop': Hint('has_loop')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'ss_palindrome'
tokens = get_tokens(code)
ast = get_ast(code)
@@ -38,7 +38,7 @@ def test(python, code):
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)):
@@ -63,11 +63,11 @@ def test(python, code):
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/dictionaries/children/common.py b/python/problems/dictionaries/children/common.py
index 437835e..b97e593 100644
--- a/python/problems/dictionaries/children/common.py
+++ b/python/problems/dictionaries/children/common.py
@@ -19,7 +19,7 @@ hint_type = {
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'children'
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)):
@@ -64,11 +64,11 @@ def test(python, code):
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/dictionaries/family/common.py b/python/problems/dictionaries/family/common.py
index 8d175e1..4f673a4 100644
--- a/python/problems/dictionaries/family/common.py
+++ b/python/problems/dictionaries/family/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 = 'family_tree'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -51,7 +51,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)):
@@ -69,11 +69,11 @@ def test(python, code):
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/dictionaries/following_words/common.py b/python/problems/dictionaries/following_words/common.py
index 501cfd2..0afaf91 100644
--- a/python/problems/dictionaries/following_words/common.py
+++ b/python/problems/dictionaries/following_words/common.py
@@ -22,7 +22,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'following_words'
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)):
@@ -59,11 +59,11 @@ def test(python, code):
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/dictionaries/freq_following_word/common.py b/python/problems/dictionaries/freq_following_word/common.py
index e00b332..557c76e 100644
--- a/python/problems/dictionaries/freq_following_word/common.py
+++ b/python/problems/dictionaries/freq_following_word/common.py
@@ -30,7 +30,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'freq_following_word'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -51,7 +51,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)):
@@ -70,11 +70,11 @@ def test(python, code):
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/dictionaries/grandchildren/common.py b/python/problems/dictionaries/grandchildren/common.py
index 0e71fba..04a8b68 100644
--- a/python/problems/dictionaries/grandchildren/common.py
+++ b/python/problems/dictionaries/grandchildren/common.py
@@ -26,7 +26,7 @@ hint_type = {
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'grandchildren'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -54,7 +54,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)):
@@ -73,11 +73,11 @@ def test(python, code):
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/dictionaries/max_characters/common.py b/python/problems/dictionaries/max_characters/common.py
index cb0c4b6..eecf50a 100644
--- a/python/problems/dictionaries/max_characters/common.py
+++ b/python/problems/dictionaries/max_characters/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 = 'maxchars'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -43,7 +43,7 @@ def test(python, code):
test_in = [('{0}({1})'.format(func_name, 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)):
@@ -61,11 +61,11 @@ def test(python, code):
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/dictionaries/most_frequent/common.py b/python/problems/dictionaries/most_frequent/common.py
index a945f1d..aaaba33 100644
--- a/python/problems/dictionaries/most_frequent/common.py
+++ b/python/problems/dictionaries/most_frequent/common.py
@@ -35,7 +35,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'most_frequent'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -53,7 +53,7 @@ def test(python, code):
test_in = [('{0}("{1}")'.format(func_name, 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)):
@@ -71,11 +71,11 @@ def test(python, code):
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/dictionaries/show_letters/common.py b/python/problems/dictionaries/show_letters/common.py
index f69565a..29ab749 100644
--- a/python/problems/dictionaries/show_letters/common.py
+++ b/python/problems/dictionaries/show_letters/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 = 'show_letters'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -38,7 +38,7 @@ def test(python, code):
test_in = [('{0}{1}'.format(func_name, 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):
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/dictionaries/successors/common.py b/python/problems/dictionaries/successors/common.py
index 5f824f5..722e22e 100644
--- a/python/problems/dictionaries/successors/common.py
+++ b/python/problems/dictionaries/successors/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 = 'successors'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -52,7 +52,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)):
@@ -71,11 +71,11 @@ def test(python, code):
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/dictionaries/text/common.py b/python/problems/dictionaries/text/common.py
index 134f69b..ab6deac 100644
--- a/python/problems/dictionaries/text/common.py
+++ b/python/problems/dictionaries/text/common.py
@@ -38,7 +38,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'text'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -56,7 +56,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)):
@@ -75,11 +75,11 @@ def test(python, code):
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/dictionaries/transactions/common.py b/python/problems/dictionaries/transactions/common.py
index 66d6387..a3a173d 100644
--- a/python/problems/dictionaries/transactions/common.py
+++ b/python/problems/dictionaries/transactions/common.py
@@ -24,7 +24,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'transactions'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -42,7 +42,7 @@ def test(python, code):
test_in = [('{0}{1}'.format(func_name, 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)):
@@ -60,11 +60,11 @@ def test(python, code):
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/dictionaries/waiter/common.py b/python/problems/dictionaries/waiter/common.py
index bcda759..41b592d 100644
--- a/python/problems/dictionaries/waiter/common.py
+++ b/python/problems/dictionaries/waiter/common.py
@@ -29,7 +29,7 @@ def comp(solution, test):
return True
return dict(solution) == test
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'orders'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -52,7 +52,7 @@ def test(python, code):
for l in in_out+in_out_empty]
test_out = [l[1] for l in in_out+in_out_empty]
- 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)):
@@ -70,11 +70,11 @@ def test(python, code):
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/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
diff --git a/python/problems/functions_and_modules/all/common.py b/python/problems/functions_and_modules/all/common.py
index 6df5597..68428ba 100644
--- a/python/problems/functions_and_modules/all/common.py
+++ b/python/problems/functions_and_modules/all/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 = 'all'
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)):
@@ -59,11 +59,11 @@ def test(python, code):
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_and_modules/any/common.py b/python/problems/functions_and_modules/any/common.py
index 3834c8a..ee38613 100644
--- a/python/problems/functions_and_modules/any/common.py
+++ b/python/problems/functions_and_modules/any/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 = 'any'
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)):
@@ -57,11 +57,11 @@ def test(python, code):
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_and_modules/caesar_cipher/common.py b/python/problems/functions_and_modules/caesar_cipher/common.py
index b85c847..976c83c 100644
--- a/python/problems/functions_and_modules/caesar_cipher/common.py
+++ b/python/problems/functions_and_modules/caesar_cipher/common.py
@@ -24,7 +24,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'caesar'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -48,7 +48,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)):
@@ -66,11 +66,11 @@ def test(python, code):
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_and_modules/dominoes/common.py b/python/problems/functions_and_modules/dominoes/common.py
index eb5d8e8..283452d 100644
--- a/python/problems/functions_and_modules/dominoes/common.py
+++ b/python/problems/functions_and_modules/dominoes/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 = 'dominoes'
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)):
@@ -56,11 +56,11 @@ def test(python, code):
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_and_modules/largest_sublist/common.py b/python/problems/functions_and_modules/largest_sublist/common.py
index 44a661d..dfa33dd 100644
--- a/python/problems/functions_and_modules/largest_sublist/common.py
+++ b/python/problems/functions_and_modules/largest_sublist/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 = 'largest_sublist'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -42,7 +42,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)):
@@ -60,11 +60,11 @@ def test(python, code):
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_and_modules/lists_sum/common.py b/python/problems/functions_and_modules/lists_sum/common.py
index cfdb179..37f5f91 100644
--- a/python/problems/functions_and_modules/lists_sum/common.py
+++ b/python/problems/functions_and_modules/lists_sum/common.py
@@ -22,7 +22,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
func_name = 'lists_sum'
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)):
@@ -59,11 +59,11 @@ def test(python, code):
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_and_modules/longest_word/common.py b/python/problems/functions_and_modules/longest_word/common.py
index addf024..db8e92c 100644
--- a/python/problems/functions_and_modules/longest_word/common.py
+++ b/python/problems/functions_and_modules/longest_word/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 = 'longest'
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)):
@@ -58,11 +58,11 @@ def test(python, code):
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_and_modules/map/common.py b/python/problems/functions_and_modules/map/common.py
index 2d0f3f8..57bff55 100644
--- a/python/problems/functions_and_modules/map/common.py
+++ b/python/problems/functions_and_modules/map/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 = 'map'
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+'({l[0]},{l[1]})'.format(l = 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)):
@@ -52,11 +52,11 @@ def test(python, code):
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_and_modules/multiplicative_range/common.py b/python/problems/functions_and_modules/multiplicative_range/common.py
index 3cb266e..d310a95 100644
--- a/python/problems/functions_and_modules/multiplicative_range/common.py
+++ b/python/problems/functions_and_modules/multiplicative_range/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 = 'mrange'
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)):
@@ -55,11 +55,11 @@ def test(python, code):
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_and_modules/similarity/common.py b/python/problems/functions_and_modules/similarity/common.py
index 0f13fcf..59fc475 100644
--- a/python/problems/functions_and_modules/similarity/common.py
+++ b/python/problems/functions_and_modules/similarity/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 = 'similarity'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -42,7 +42,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)):
@@ -60,11 +60,11 @@ def test(python, code):
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_and_modules/suspicious_words/common.py b/python/problems/functions_and_modules/suspicious_words/common.py
index 71000d0..2967e01 100644
--- a/python/problems/functions_and_modules/suspicious_words/common.py
+++ b/python/problems/functions_and_modules/suspicious_words/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 = 'suspicious'
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+"('"+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):
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/introduction/average/common.py b/python/problems/introduction/average/common.py
index fa152e9..bdf34d7 100644
--- a/python/problems/introduction/average/common.py
+++ b/python/problems/introduction/average/common.py
@@ -30,7 +30,7 @@ hint_type = {
-def test(python, code):
+def test(python, code, aux_code=''):
# List of inputs: (expression to eval, stdin).
test_in = [
(None, '2\n4\n5\n'),
@@ -51,7 +51,7 @@ def test(python, code):
]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct = 0
@@ -73,12 +73,12 @@ def test(python, code):
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
test_in = [(None, '1\n1\n4\n')]
- answer = python(code=code, inputs=test_in, timeout=1.0)
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
exc = answer[0][3]
exc_hint = get_exception_desc(answer[0][3])
if exc:
diff --git a/python/problems/introduction/ballistics/common.py b/python/problems/introduction/ballistics/common.py
index 326650b..beb1c6c 100644
--- a/python/problems/introduction/ballistics/common.py
+++ b/python/problems/introduction/ballistics/common.py
@@ -36,7 +36,7 @@ def contains_negative(s):
return True
return False
-def test(python, code):
+def test(python, code, aux_code=''):
# List of inputs: (expression to eval, stdin).
test_in = [
(None, '45\n100\n'),
@@ -69,7 +69,7 @@ def test(python, code):
]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct = 0
@@ -90,12 +90,12 @@ 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
test_in = [(None, '5\n10\n')]
- answer = python(code=code, inputs=test_in, timeout=1.0)
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
exc = answer[0][3]
exc_hint = get_exception_desc(answer[0][3])
if exc:
diff --git a/python/problems/introduction/fahrenheit_to_celsius/common.py b/python/problems/introduction/fahrenheit_to_celsius/common.py
index a62d2ae..3a2095a 100644
--- a/python/problems/introduction/fahrenheit_to_celsius/common.py
+++ b/python/problems/introduction/fahrenheit_to_celsius/common.py
@@ -23,7 +23,7 @@ hint_type = {
'final_hint': Hint('final_hint'),
}
-def test(python, code):
+def test(python, code, aux_code=''):
# List of inputs: (expression to eval, stdin).
test_in = [
(None, '32\n'),
@@ -41,7 +41,7 @@ def test(python, code):
]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct = 0
@@ -61,12 +61,12 @@ 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
test_in = [(None, '212\n')]
- answer = python(code=code, inputs=test_in, timeout=1.0)
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
exc = answer[0][3]
exc_hint = get_exception_desc(answer[0][3])
if exc:
diff --git a/python/problems/introduction/fast_fingers/common.py b/python/problems/introduction/fast_fingers/common.py
index fe87555..af08c63 100644
--- a/python/problems/introduction/fast_fingers/common.py
+++ b/python/problems/introduction/fast_fingers/common.py
@@ -24,7 +24,7 @@ hint_type = {
'printing': Hint('printing'),
}
-def test(python, code):
+def test(python, code, aux_code=''):
# List of inputs: (expression to eval, stdin).
test_in = [
(None, '1\n'),
@@ -42,7 +42,7 @@ def test(python, code):
]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct = 0
@@ -60,12 +60,12 @@ def test(python, code):
hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
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
test_in = [(None, '212\n')]
- answer = python(code=code, inputs=test_in, timeout=1.0)
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
exc = answer[0][3]
exc_hint = get_exception_desc(answer[0][3])
# if have an exception!
diff --git a/python/problems/introduction/fast_fingers_2/common.py b/python/problems/introduction/fast_fingers_2/common.py
index 01ad941..fe50111 100644
--- a/python/problems/introduction/fast_fingers_2/common.py
+++ b/python/problems/introduction/fast_fingers_2/common.py
@@ -33,7 +33,7 @@ hint_type = {
'final_hint_noif': Hint('final_hint_noif')
}
-def test(python, code):
+def test(python, code, aux_code=''):
# List of inputs: (expression to eval, stdin).
test = [(5,'25\n'),
(6, '29\n'),
@@ -58,7 +58,7 @@ def test(python, code):
# hook randint
tcode = random_code.format(t[0]) + code
- answers = python(code=tcode, inputs=[(None, t[1])], timeout=1.0)
+ answers = python(code=aux_code+tcode, inputs=[(None, t[1])], timeout=1.0)
output = answers[0][1]
if str(test_out[ti]) in output and str(not test_out[ti]) not in output:
@@ -81,12 +81,12 @@ def test(python, code):
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
test_in = [(None, '16\n')]
- answer = python(code=code, inputs=test_in, timeout=1.0)
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
exc = answer[0][3]
exc_hint = get_exception_desc(answer[0][3])
# if have an exception!
diff --git a/python/problems/introduction/leap_year/common.py b/python/problems/introduction/leap_year/common.py
index 7dc7318..414f295 100644
--- a/python/problems/introduction/leap_year/common.py
+++ b/python/problems/introduction/leap_year/common.py
@@ -23,7 +23,7 @@ hint_type = {
'final_hint': Hint('final_hint'),
}
-def test(python, code):
+def test(python, code, aux_code=''):
# List of inputs: (expression to eval, stdin).
test_in = [
(None, '1900\n'),
@@ -41,7 +41,7 @@ def test(python, code):
]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct = 0
@@ -61,12 +61,12 @@ 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
test_in = [(None, '212\n')]
- answer = python(code=code, inputs=test_in, timeout=1.0)
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
exc = answer[0][3]
exc_hint = get_exception_desc(answer[0][3])
if exc:
diff --git a/python/problems/introduction/pythagorean_theorem/common.py b/python/problems/introduction/pythagorean_theorem/common.py
index d38ae66..79eca5b 100644
--- a/python/problems/introduction/pythagorean_theorem/common.py
+++ b/python/problems/introduction/pythagorean_theorem/common.py
@@ -24,7 +24,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
# List of inputs: (expression to eval, stdin).
test_in = [
(None, '3\n4\n'),
@@ -47,7 +47,7 @@ def test(python, code):
]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct = 0
@@ -67,12 +67,12 @@ 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
test_in = [(None, '3\n4\n')]
- answer = python(code=code, inputs=test_in, timeout=1.0)
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
exc = answer[0][3]
exc_hint = get_exception_desc(answer[0][3])
if exc:
diff --git a/python/problems/lists_and_for/calculator_polish/common.py b/python/problems/lists_and_for/calculator_polish/common.py
index 790f116..cd18f3b 100644
--- a/python/problems/lists_and_for/calculator_polish/common.py
+++ b/python/problems/lists_and_for/calculator_polish/common.py
@@ -42,7 +42,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
in_out = [
(['6 3 +'], [9]),
(['6 3 -'], [3]),
@@ -62,7 +62,7 @@ def test(python, code):
test_in = [(None, '\n'.join(s[0])+'\n') for s in in_out]
test_out = [s[1] for s in in_out]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct = 0
@@ -83,11 +83,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/lists_and_for/contains_42/common.py b/python/problems/lists_and_for/contains_42/common.py
index dfaab56..9118c5e 100644
--- a/python/problems/lists_and_for/contains_42/common.py
+++ b/python/problems/lists_and_for/contains_42/common.py
@@ -28,7 +28,7 @@ hint_type = {
'final_hint_nobreak': Hint('final_hint_nobreak')
}
-def test(python, code):
+def test(python, code, aux_code=''):
tokens = get_tokens(code)
test_xs = [[42, 5, 4, -7, 2, 12, -3, -4, 11, 42, 2],
@@ -59,7 +59,7 @@ def test(python, code):
flags = re.DOTALL | re.MULTILINE)
# use python session to call tcode
- answers = python(code=tcode, inputs=[(None, None)], timeout=1.0)
+ answers = python(code=aux_code+tcode, inputs=[(None, None)], timeout=1.0)
output = answers[0][1]
if str(test_out[xs_i]) in output and \
@@ -80,9 +80,9 @@ def test(python, code):
hints.append({'id' : 'final_hint_nobreak'})
return passed, hints
-def hint(python, code):
+def hint(python, code, aux_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/lists_and_for/contains_multiples/common.py b/python/problems/lists_and_for/contains_multiples/common.py
index 84eaca9..4fd349d 100644
--- a/python/problems/lists_and_for/contains_multiples/common.py
+++ b/python/problems/lists_and_for/contains_multiples/common.py
@@ -21,7 +21,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
in_out = [
([], False),
([0], True),
@@ -51,7 +51,7 @@ def test(python, code):
flags = re.DOTALL | re.MULTILINE)
# use python session to call tcode
- answers = python(code=tcode, inputs=[(None, None)], timeout=1.0)
+ answers = python(code=aux_code+tcode, inputs=[(None, None)], timeout=1.0)
output = answers[0][1]
if str(test_out[xs_i]) in output and \
@@ -69,11 +69,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/lists_and_for/contains_string/common.py b/python/problems/lists_and_for/contains_string/common.py
index c307a9c..eb724f0 100644
--- a/python/problems/lists_and_for/contains_string/common.py
+++ b/python/problems/lists_and_for/contains_string/common.py
@@ -26,7 +26,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
test_xs = [['waldo', 'foo', 'bar', 'baz'],
['foo', 'bar', 'baz', 'Waldo', 'foobar'],
['foo', 'bar', 'baz', 'Waldo'],
@@ -53,7 +53,7 @@ def test(python, code):
flags = re.DOTALL | re.MULTILINE)
# use python session to call tcode
- answers = python(code=tcode, inputs=[(None, None)], timeout=1.0)
+ answers = python(code=aux_code+tcode, inputs=[(None, None)], timeout=1.0)
output = answers[0][1]
if str(test_out[xs_i]) in output and \
@@ -72,9 +72,9 @@ def test(python, code):
return passed, hints
-def hint(python, code):
+def hint(python, code, aux_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/lists_and_for/counting/common.py b/python/problems/lists_and_for/counting/common.py
index 5438030..295ca57 100644
--- a/python/problems/lists_and_for/counting/common.py
+++ b/python/problems/lists_and_for/counting/common.py
@@ -26,7 +26,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
test_xs = [[42, 5, 4, -7, 2, 42, -3, -4, 11, 42, 2],
[42, 5, 4, -7, 2, 12, 42, -4, 11, 2],
[5, 4, -7, 2, 12, -3, -4, 11, 2],
@@ -57,7 +57,7 @@ def test(python, code):
flags = re.DOTALL | re.MULTILINE)
# use python session to call tcode
- answers = python(code=tcode, inputs=[(None, None)], timeout=1.0)
+ answers = python(code=aux_code+tcode, inputs=[(None, None)], timeout=1.0)
output = answers[0][1]
if str(test_out[xs_i]) in output:
@@ -74,9 +74,9 @@ def test(python, code):
hints.append({'id': 'final_hint'})
return passed, hints
-def hint(python, code):
+def hint(python, code, aux_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/lists_and_for/divisors/common.py b/python/problems/lists_and_for/divisors/common.py
index 429e212..d1615ff 100644
--- a/python/problems/lists_and_for/divisors/common.py
+++ b/python/problems/lists_and_for/divisors/common.py
@@ -24,7 +24,7 @@ hint_type = {
'last_number': Hint('last_number'),
}
-def test(python, code):
+def test(python, code, aux_code=''):
test_in = [
(None, '8\n'),
(None, '6\n'),
@@ -36,7 +36,7 @@ def test(python, code):
values = [8, 6, 5, 2, 15, 20]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct, tin = 0, None
@@ -65,9 +65,9 @@ def test(python, code):
hints.append({'id': 'final_hint'})
return passed, hints
-def hint(python, code):
+def hint(python, code, aux_code=''):
# run one test first to see if there are any exceptions
- answer = python(code=code, inputs=[(None, '8\n')], timeout=1.0)
+ answer = python(code=aux_code+code, inputs=[(None, '8\n')], timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc:
if 'ZeroDivisionError' in answer[0][3]:
diff --git a/python/problems/lists_and_for/divisors_sum/common.py b/python/problems/lists_and_for/divisors_sum/common.py
index 65333f0..69e6ade 100644
--- a/python/problems/lists_and_for/divisors_sum/common.py
+++ b/python/problems/lists_and_for/divisors_sum/common.py
@@ -27,7 +27,7 @@ hint_type = {
'summing': Hint('summing'),
}
-def test(python, code):
+def test(python, code, aux_code=''):
test_in = [
(None, '8\n'),
(None, '6\n'),
@@ -45,7 +45,7 @@ def test(python, code):
22]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct, tin = 0, None
@@ -64,10 +64,10 @@ 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, '8\n')], timeout=1.0)
+ answer = python(code=aux_code+code, inputs=[(None, '8\n')], timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc:
if 'ZeroDivisionError' in answer[0][3]:
diff --git a/python/problems/lists_and_for/every_third/common.py b/python/problems/lists_and_for/every_third/common.py
index da4a2fa..3ad1ae6 100644
--- a/python/problems/lists_and_for/every_third/common.py
+++ b/python/problems/lists_and_for/every_third/common.py
@@ -22,7 +22,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
in_out = [
([], []),
([0], []),
@@ -47,7 +47,7 @@ def test(python, code):
flags = re.DOTALL | re.MULTILINE)
# use python session to call tcode
- answers = python(code=tcode, inputs=[(None, None)], timeout=1.0)
+ answers = python(code=aux_code+tcode, inputs=[(None, None)], timeout=1.0)
output = answers[0][1]
if str(test_out[xs_i]) in output:
@@ -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/lists_and_for/perfect_numbers/common.py b/python/problems/lists_and_for/perfect_numbers/common.py
index 1369188..64a4348 100644
--- a/python/problems/lists_and_for/perfect_numbers/common.py
+++ b/python/problems/lists_and_for/perfect_numbers/common.py
@@ -30,7 +30,7 @@ hint_type = {
'summing': Hint('summing'),
}
-def test(python, code):
+def test(python, code, aux_code=''):
test_in = [
(None, '8\n'),
(None, '6\n'),
@@ -48,7 +48,7 @@ def test(python, code):
22]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct, tin = 0, None
@@ -67,10 +67,10 @@ 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, '8\n')], timeout=1.0)
+ answer = python(code=aux_code+code, inputs=[(None, '8\n')], timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc:
if 'ZeroDivisionError' in answer[0][3]:
diff --git a/python/problems/lists_and_for/places/common.py b/python/problems/lists_and_for/places/common.py
index df62e7a..01a003d 100644
--- a/python/problems/lists_and_for/places/common.py
+++ b/python/problems/lists_and_for/places/common.py
@@ -21,7 +21,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
in_out = [
([], []),
([0], []),
@@ -50,7 +50,7 @@ def test(python, code):
flags = re.DOTALL | re.MULTILINE)
# use python session to call tcode
- answers = python(code=tcode, inputs=[(None, None)], timeout=1.0)
+ answers = python(code=aux_code+tcode, inputs=[(None, None)], timeout=1.0)
output = answers[0][1]
if str(test_out[xs_i]) in output:
@@ -67,11 +67,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/lists_and_for/prefix/common.py b/python/problems/lists_and_for/prefix/common.py
index 3cc57fb..9725350 100644
--- a/python/problems/lists_and_for/prefix/common.py
+++ b/python/problems/lists_and_for/prefix/common.py
@@ -20,7 +20,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
in_out = [
('a', ['', 'a']),
('ab', ['', 'a', 'ab']),
@@ -31,7 +31,7 @@ def test(python, code):
test_in = [(None, s[0]+'\n') for s in in_out]
test_out = [str(s[1]) for s in in_out]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct = 0
@@ -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/lists_and_for/split_word/common.py b/python/problems/lists_and_for/split_word/common.py
index 95f87f7..6412ddc 100644
--- a/python/problems/lists_and_for/split_word/common.py
+++ b/python/problems/lists_and_for/split_word/common.py
@@ -20,7 +20,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
in_out = [
('a', [('', 'a'), ('a', '')]),
('ab', [('', 'ab'), ('a', 'b'), ('ab', '')]),
@@ -31,7 +31,7 @@ def test(python, code):
test_in = [(None, s[0]+'\n') for s in in_out]
test_out = [str(s[1]) for s in in_out]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct = 0
@@ -52,11 +52,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/lists_and_for/substrings/common.py b/python/problems/lists_and_for/substrings/common.py
index 3a996c2..0efcc6c 100644
--- a/python/problems/lists_and_for/substrings/common.py
+++ b/python/problems/lists_and_for/substrings/common.py
@@ -23,7 +23,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
+def test(python, code, aux_code=''):
in_out = [
('a', ['', 'a']),
('ab', ['', 'a', 'b', 'ab']),
@@ -34,7 +34,7 @@ def test(python, code):
test_in = [(None, s[0]+'\n') for s in in_out]
test_out = [str(s[1]) for s in in_out]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct = 0
@@ -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/recursion/depth_to/common.py b/python/problems/recursion/depth_to/common.py
index 3aad348..0efaf76 100644
--- a/python/problems/recursion/depth_to/common.py
+++ b/python/problems/recursion/depth_to/common.py
@@ -7,6 +7,7 @@ from server.hints import Hint
id = 20804
number = 4
visible = True
+facts = 'family_tree'
solution = '''\
def depthto(fr, to):
@@ -18,43 +19,11 @@ def depthto(fr, to):
return d + 1
'''
-precode = """
-children = {
- "Adam": ["Matjaž", "Cilka", "Daniel", "Erik"],
- "Aleksander": [],
- "Alenka": [],
- "Barbara": [],
- "Cilka": [],
- "Daniel": ["Elizabeta", "Hans"],
- "Erik": [],
- "Elizabeta": ["Ludvik", "Jurij", "Barbara", "Herman", "Mihael"],
- "Franc": [],
- "Herman": ["Margareta"],
- "Hans": [],
- "Jožef": ["Alenka", "Aleksander", "Petra"],
- "Jurij": ["Franc", "Jožef"],
- "Ludvik": [],
- "Margareta": [],
- "Matjaž": ["Viljem"],
- "Mihael": [],
- "Petra": [],
- "Tadeja": [],
- "Viljem": ["Tadeja"],
-}
-
-age = {
- "Adam": 111, "Matjaž": 90, "Cilka": 88, "Daniel": 85, "Erik": 83,
- "Viljem": 58, "Tadeja": 20, "Elizabeta": 67, "Hans": 64, "Ludvik": 50,
- "Jurij": 49, "Barbara": 45, "Herman": 39, "Mihael": 32, "Franc": 30,
- "Jožef": 29, "Margareta": 10, "Alenka": 5, "Aleksander": 7, "Petra": 9
-}"""
-
hint_type = {
'final_hint': Hint('final_hint')
}
-def test(python, code):
- code = precode + "\n" + code
+def test(python, code, aux_code=''):
func_name = 'depthto'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -75,7 +44,7 @@ def test(python, code):
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)):
@@ -96,11 +65,11 @@ def test(python, code):
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/recursion/family_tree_name/common.py b/python/problems/recursion/family_tree_name/common.py
index d924665..af549be 100644
--- a/python/problems/recursion/family_tree_name/common.py
+++ b/python/problems/recursion/family_tree_name/common.py
@@ -7,6 +7,7 @@ from server.hints import Hint
id = 20801
number = 1
visible = True
+facts = 'family_tree'
solution = '''\
def printnames(name):
@@ -19,40 +20,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-precode = """
-children = {
- "Adam": ["Matjaž", "Cilka", "Daniel", "Erik"],
- "Aleksander": [],
- "Alenka": [],
- "Barbara": [],
- "Cilka": [],
- "Daniel": ["Elizabeta", "Hans"],
- "Erik": [],
- "Elizabeta": ["Ludvik", "Jurij", "Barbara", "Herman", "Mihael"],
- "Franc": [],
- "Herman": ["Margareta"],
- "Hans": [],
- "Jožef": ["Alenka", "Aleksander", "Petra"],
- "Jurij": ["Franc", "Jožef"],
- "Ludvik": [],
- "Margareta": [],
- "Matjaž": ["Viljem"],
- "Mihael": [],
- "Petra": [],
- "Tadeja": [],
- "Viljem": ["Tadeja"],
-}
-
-age = {
- "Adam": 111, "Matjaž": 90, "Cilka": 88, "Daniel": 85, "Erik": 83,
- "Viljem": 58, "Tadeja": 20, "Elizabeta": 67, "Hans": 64, "Ludvik": 50,
- "Jurij": 49, "Barbara": 45, "Herman": 39, "Mihael": 32, "Franc": 30,
- "Jožef": 29, "Margareta": 10, "Alenka": 5, "Aleksander": 7, "Petra": 9
-}"""
-
-def test(python, code):
- code = precode + "\n" + code
-
+def test(python, code, aux_code=''):
func_name = 'printnames'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -71,7 +39,7 @@ def test(python, code):
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)):
@@ -92,11 +60,11 @@ def test(python, code):
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/recursion/family_tree_name_list/common.py b/python/problems/recursion/family_tree_name_list/common.py
index 880d8b1..c0284de 100644
--- a/python/problems/recursion/family_tree_name_list/common.py
+++ b/python/problems/recursion/family_tree_name_list/common.py
@@ -7,6 +7,7 @@ from server.hints import Hint
id = 20802
number = 2
visible = True
+facts = 'family_tree'
solution = '''\
def names(name):
@@ -20,40 +21,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-precode = """
-children = {
- "Adam": ["Matjaž", "Cilka", "Daniel", "Erik"],
- "Aleksander": [],
- "Alenka": [],
- "Barbara": [],
- "Cilka": [],
- "Daniel": ["Elizabeta", "Hans"],
- "Erik": [],
- "Elizabeta": ["Ludvik", "Jurij", "Barbara", "Herman", "Mihael"],
- "Franc": [],
- "Herman": ["Margareta"],
- "Hans": [],
- "Jožef": ["Alenka", "Aleksander", "Petra"],
- "Jurij": ["Franc", "Jožef"],
- "Ludvik": [],
- "Margareta": [],
- "Matjaž": ["Viljem"],
- "Mihael": [],
- "Petra": [],
- "Tadeja": [],
- "Viljem": ["Tadeja"],
-}
-
-age = {
- "Adam": 111, "Matjaž": 90, "Cilka": 88, "Daniel": 85, "Erik": 83,
- "Viljem": 58, "Tadeja": 20, "Elizabeta": 67, "Hans": 64, "Ludvik": 50,
- "Jurij": 49, "Barbara": 45, "Herman": 39, "Mihael": 32, "Franc": 30,
- "Jožef": 29, "Margareta": 10, "Alenka": 5, "Aleksander": 7, "Petra": 9
-}"""
-
-def test(python, code):
- code = precode + "\n" + code
-
+def test(python, code, aux_code=''):
func_name = 'names'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -72,7 +40,7 @@ def test(python, code):
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)):
@@ -93,11 +61,11 @@ def test(python, code):
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/recursion/family_tree_youngest/common.py b/python/problems/recursion/family_tree_youngest/common.py
index 099c1d3..0acfe79 100644
--- a/python/problems/recursion/family_tree_youngest/common.py
+++ b/python/problems/recursion/family_tree_youngest/common.py
@@ -20,40 +20,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-precode = """
-children = {
- "Adam": ["Matjaž", "Cilka", "Daniel", "Erik"],
- "Aleksander": [],
- "Alenka": [],
- "Barbara": [],
- "Cilka": [],
- "Daniel": ["Elizabeta", "Hans"],
- "Erik": [],
- "Elizabeta": ["Ludvik", "Jurij", "Barbara", "Herman", "Mihael"],
- "Franc": [],
- "Herman": ["Margareta"],
- "Hans": [],
- "Jožef": ["Alenka", "Aleksander", "Petra"],
- "Jurij": ["Franc", "Jožef"],
- "Ludvik": [],
- "Margareta": [],
- "Matjaž": ["Viljem"],
- "Mihael": [],
- "Petra": [],
- "Tadeja": [],
- "Viljem": ["Tadeja"],
-}
-
-age = {
- "Adam": 111, "Matjaž": 90, "Cilka": 88, "Daniel": 85, "Erik": 83,
- "Viljem": 58, "Tadeja": 20, "Elizabeta": 67, "Hans": 64, "Ludvik": 50,
- "Jurij": 49, "Barbara": 45, "Herman": 39, "Mihael": 32, "Franc": 30,
- "Jožef": 29, "Margareta": 10, "Alenka": 5, "Aleksander": 7, "Petra": 9
-}"""
-
-def test(python, code):
- code = precode + "\n" + code
-
+def test(python, code, aux_code=''):
func_name = 'youngest'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -72,7 +39,7 @@ def test(python, code):
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)):
@@ -93,11 +60,11 @@ def test(python, code):
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/recursion/path_to/common.py b/python/problems/recursion/path_to/common.py
index cf63b6c..6b92c24 100644
--- a/python/problems/recursion/path_to/common.py
+++ b/python/problems/recursion/path_to/common.py
@@ -7,6 +7,7 @@ from server.hints import Hint
id = 20805
number = 5
visible = True
+facts = 'family_tree'
solution = '''\
def pathto(fr, to):
@@ -22,40 +23,7 @@ hint_type = {
'final_hint': Hint('final_hint')
}
-precode = """
-children = {
- "Adam": ["Matjaž", "Cilka", "Daniel", "Erik"],
- "Aleksander": [],
- "Alenka": [],
- "Barbara": [],
- "Cilka": [],
- "Daniel": ["Elizabeta", "Hans"],
- "Erik": [],
- "Elizabeta": ["Ludvik", "Jurij", "Barbara", "Herman", "Mihael"],
- "Franc": [],
- "Herman": ["Margareta"],
- "Hans": [],
- "Jožef": ["Alenka", "Aleksander", "Petra"],
- "Jurij": ["Franc", "Jožef"],
- "Ludvik": [],
- "Margareta": [],
- "Matjaž": ["Viljem"],
- "Mihael": [],
- "Petra": [],
- "Tadeja": [],
- "Viljem": ["Tadeja"],
-}
-
-age = {
- "Adam": 111, "Matjaž": 90, "Cilka": 88, "Daniel": 85, "Erik": 83,
- "Viljem": 58, "Tadeja": 20, "Elizabeta": 67, "Hans": 64, "Ludvik": 50,
- "Jurij": 49, "Barbara": 45, "Herman": 39, "Mihael": 32, "Franc": 30,
- "Jožef": 29, "Margareta": 10, "Alenka": 5, "Aleksander": 7, "Petra": 9
-}"""
-
-def test(python, code):
- code = precode + "\n" + code
-
+def test(python, code, aux_code=''):
func_name = 'pathto'
tokens = get_tokens(code)
if not has_token_sequence(tokens, ['def', func_name]):
@@ -76,7 +44,7 @@ def test(python, code):
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)):
@@ -97,11 +65,11 @@ def test(python, code):
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/while_and_if/buy_five/common.py b/python/problems/while_and_if/buy_five/common.py
index 0ec7238..ef85b07 100644
--- a/python/problems/while_and_if/buy_five/common.py
+++ b/python/problems/while_and_if/buy_five/common.py
@@ -23,7 +23,7 @@ hint_type = {
'nonumber': Hint('nonumber'),
}
-def test(python, code):
+def test(python, code, aux_code=''):
# List of inputs: (expression to eval, stdin).
test_in = [
(None, '1\n1\n1\n1\n1\n'),
@@ -42,7 +42,7 @@ def test(python, code):
]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct = 0
@@ -60,10 +60,10 @@ def test(python, code):
hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
return passed, hints
-def hint(python, code):
+def hint(python, code, aux_code=''):
# run one test first to see if there are any exceptions
test_in = [(None, '1\n1\n1\n1\n1\n')]
- answer = python(code=code, inputs=test_in, timeout=1.0)
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc: return exc
diff --git a/python/problems/while_and_if/checking_account/common.py b/python/problems/while_and_if/checking_account/common.py
index 178297f..61822de 100644
--- a/python/problems/while_and_if/checking_account/common.py
+++ b/python/problems/while_and_if/checking_account/common.py
@@ -19,7 +19,7 @@ hint_type = {
'while_condition': Hint('while_condition'),
}
-def test(python, code):
+def test(python, code, aux_code=''):
# List of inputs: (expression to eval, stdin).
test_in = [
(None, '23\n15\n-30\n10\n100\n-200\n-50\n'),
@@ -38,7 +38,7 @@ def test(python, code):
]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct = 0
@@ -59,12 +59,12 @@ def test(python, code):
'bancrupt': str(tout[1])}})
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
test_in = [(None, '23\n15\n-30\n8\n10\n100\n-200\n-50\n')]
- answer = python(code=code, inputs=test_in, timeout=1.0)
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc:
return exc
diff --git a/python/problems/while_and_if/competition/common.py b/python/problems/while_and_if/competition/common.py
index 2615fd5..9461f7d 100644
--- a/python/problems/while_and_if/competition/common.py
+++ b/python/problems/while_and_if/competition/common.py
@@ -24,7 +24,7 @@ hint_type = {
}
-def test(python, code):
+def test(python, code, aux_code=''):
# List of inputs: (expression to eval, stdin).
test_in = [
(None, '3\n2\n4\n1\n'),
@@ -43,7 +43,7 @@ def test(python, code):
]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct = 0
@@ -61,10 +61,10 @@ def test(python, code):
hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
return passed, hints
-def hint(python, code):
+def hint(python, code, aux_code=''):
# run one test first to see if there are any exceptions
test_in = [(None, '5\n1\n1\n1\n1\n1\n')]
- answer = python(code=code, inputs=test_in, timeout=1.0)
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc: return exc
diff --git a/python/problems/while_and_if/consumers_anonymous/common.py b/python/problems/while_and_if/consumers_anonymous/common.py
index 5428cd9..c5df9cf 100644
--- a/python/problems/while_and_if/consumers_anonymous/common.py
+++ b/python/problems/while_and_if/consumers_anonymous/common.py
@@ -33,7 +33,7 @@ hint_type = {
'problematic_test_case': Hint('problematic_test_case'),
}
-def test(python, code):
+def test(python, code, aux_code=''):
# List of inputs: (expression to eval, stdin).
test_in = [
(None, '10\n5\n0\n'),
@@ -56,7 +56,7 @@ def test(python, code):
]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct = 0
@@ -79,7 +79,7 @@ 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
@@ -87,7 +87,7 @@ def hint(python, code):
(None, '10\n5\n90\n'),
(None, '2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n')]
- answer = python(code=code, inputs=test_in, timeout=1.0)
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc:
if 'NameError' in answer[0][3]:
diff --git a/python/problems/while_and_if/minimax/common.py b/python/problems/while_and_if/minimax/common.py
index 7e367c2..8d2635b 100644
--- a/python/problems/while_and_if/minimax/common.py
+++ b/python/problems/while_and_if/minimax/common.py
@@ -32,7 +32,7 @@ hint_type = {
'average': Hint('while_condition'),
}
-def test(python, code):
+def test(python, code, aux_code=''):
# List of inputs: (expression to eval, stdin).
test_in = [
(None, '2\n4\n1\n0\n'),
@@ -51,7 +51,7 @@ def test(python, code):
]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct = 0
@@ -73,12 +73,12 @@ def test(python, code):
'max': str(tout[3])}})
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
test_in = [(None, '1\n1\n1\n1\n1\n0\n')]
- answer = python(code=code, inputs=test_in, timeout=1.0)
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc:
if 'NameError' in answer[0][3]:
diff --git a/python/problems/while_and_if/top_shop/common.py b/python/problems/while_and_if/top_shop/common.py
index 8edcb30..6e8b54a 100644
--- a/python/problems/while_and_if/top_shop/common.py
+++ b/python/problems/while_and_if/top_shop/common.py
@@ -27,7 +27,7 @@ hint_type = {
'minimax': Hint('minimax')
}
-def test(python, code):
+def test(python, code, aux_code=''):
# List of inputs: (expression to eval, stdin).
test_in = [
(None, '2\n4\n1\n0\n'),
@@ -46,7 +46,7 @@ def test(python, code):
]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = python(code=code, inputs=test_in, timeout=1.0)
+ answers = python(code=aux_code+code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct = 0
@@ -71,12 +71,12 @@ 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
test_in = [(None, '1\n1\n1\n1\n1\n0\n')]
- answer = python(code=code, inputs=test_in, timeout=1.0)
+ answer = python(code=aux_code+code, inputs=test_in, timeout=1.0)
exc = get_exception_desc(answer[0][3])
if exc:
if 'NameError' in answer[0][3]: