summaryrefslogtreecommitdiff
path: root/python/problems/lists_and_for/contains_42/common.py
diff options
context:
space:
mode:
authorMartin <martin@leo.fri1.uni-lj.si>2015-10-08 11:17:16 +0200
committerMartin <martin@leo.fri1.uni-lj.si>2015-10-08 11:17:16 +0200
commit1f9f6de923e4b490c42a44d660b3e32dbe11426e (patch)
treef103aa69d256f5985bdf4815b64e33af0664d88a /python/problems/lists_and_for/contains_42/common.py
parentbab0b0a2fe8b3aad853740750d4873fb929f5f41 (diff)
Added final hint to contains_42.
Diffstat (limited to 'python/problems/lists_and_for/contains_42/common.py')
-rw-r--r--python/problems/lists_and_for/contains_42/common.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/python/problems/lists_and_for/contains_42/common.py b/python/problems/lists_and_for/contains_42/common.py
index f91465f..d4c4af8 100644
--- a/python/problems/lists_and_for/contains_42/common.py
+++ b/python/problems/lists_and_for/contains_42/common.py
@@ -25,10 +25,15 @@ hint_type = {
'for_loop': Hint('for_loop'),
'if_clause': Hint('if_clause'),
'printing': Hint('printing'),
- 'print_out_for': Hint('print_out_for')
+ 'print_out_for': Hint('print_out_for'),
+ 'seen_42': Hint('seen_42'),
+ 'final_hint': Hint('final_hint'),
+ 'final_hint_nobreak': Hint('final_hint_nobreak')
}
def test(python, code):
+ tokens = get_tokens(code)
+
test_xs = [[42, 5, 4, -7, 2, 12, -3, -4, 11, 42, 2],
[42, 5, 4, -7, 2, 12, -3, -4, 11, 2],
[5, 4, -7, 2, 12, -3, -4, 11, 2],
@@ -71,6 +76,11 @@ def test(python, code):
hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_xs)}}]
if tin:
hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ else:
+ if has_token_sequence(tokens, ['break']):
+ hints.append({'id' : 'final_hint'})
+ else:
+ hints.append({'id' : 'final_hint_nobreak'})
return passed, hints
def hint(python, code):
@@ -101,5 +111,7 @@ def hint(python, code):
if not has_token_sequence(tokens, ['\n', 'print']):
return [{'id' : 'print_out_for'}]
+ if not has_token_sequence(tokens, ['=', 'True']):
+ return [{'id' : 'seen_42'}]
return None