summaryrefslogtreecommitdiff
path: root/python/problems/functions/body_mass_index
diff options
context:
space:
mode:
authorMartin Možina <martin.mozina@fri.uni-lj.si>2015-10-29 16:08:34 +0100
committerMartin Možina <martin.mozina@fri.uni-lj.si>2015-10-29 16:08:34 +0100
commit5db9e65c81bdf81ed4030040ff3666362e860d10 (patch)
tree70e58eb6d55d9689d3e8b49c9bcadbc7f8458b56 /python/problems/functions/body_mass_index
parentec7740df5a94d90758d688ac0f753e12de931360 (diff)
Bugfix.
Added some hints.
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