summaryrefslogtreecommitdiff
path: root/python/problems/functions/body_mass_index
diff options
context:
space:
mode:
Diffstat (limited to 'python/problems/functions/body_mass_index')
-rw-r--r--python/problems/functions/body_mass_index/common.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/python/problems/functions/body_mass_index/common.py b/python/problems/functions/body_mass_index/common.py
index 8e774be..1ff56b6 100644
--- a/python/problems/functions/body_mass_index/common.py
+++ b/python/problems/functions/body_mass_index/common.py
@@ -2,7 +2,7 @@
import re
from python.util import has_token_sequence, string_almost_equal, \
- string_contains_number, get_tokens, get_numbers, get_exception_desc
+ string_contains_number, get_tokens, get_numbers, get_exception_desc, almost_equal
from server.hints import Hint
id = 226
@@ -42,8 +42,19 @@ def test(python, code):
n_correct = 0
tin, tout = None, None
for i, (ans, to) in enumerate(zip(answers, test_out)):
- n_correct += ans[0] == to
- if ans[0] != to:
+ corr = 0
+ if isinstance(ans[0], list) and len(ans[0]) == len(to):
+ corr = 1
+ for v1, v2 in zip(ans[0], to):
+ if not isinstance(v1, tuple) or len(v1) != len(v2):
+ corr = 0
+ break
+ if v1[0] != v2[0] or not almost_equal(v1[1], v2[1], 2):
+ corr = 0
+ break
+
+ n_correct += corr
+ if not corr:
tin = test_in[i][0]
tout = to