summaryrefslogtreecommitdiff
path: root/python/problems/while_and_if
diff options
context:
space:
mode:
Diffstat (limited to 'python/problems/while_and_if')
-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
6 files changed, 24 insertions, 24 deletions
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]: