From 5db9e65c81bdf81ed4030040ff3666362e860d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Mo=C5=BEina?= Date: Thu, 29 Oct 2015 16:08:34 +0100 Subject: Bugfix. Added some hints. --- python/problems/functions/body_mass_index_2/common.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'python/problems/functions/body_mass_index_2/common.py') diff --git a/python/problems/functions/body_mass_index_2/common.py b/python/problems/functions/body_mass_index_2/common.py index c6cf2b3..176a59d 100644 --- a/python/problems/functions/body_mass_index_2/common.py +++ b/python/problems/functions/body_mass_index_2/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 = 227 @@ -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 -- cgit v1.2.1