diff options
author | Aleksander Sadikov <aleksander.sadikov@fri.uni-lj.si> | 2016-03-12 17:15:59 +0100 |
---|---|---|
committer | Aleksander Sadikov <aleksander.sadikov@fri.uni-lj.si> | 2016-03-12 17:15:59 +0100 |
commit | e5674c50d1d4a25961d0244198dedbceb2a926e9 (patch) | |
tree | 2e74b1ee312d66fdb14d14c11287c8fafdf3120d /prolog | |
parent | d248db88cb8da1b9c2d360f707c923c2bf902545 (diff) |
Hints for last_elem/2 added.
Diffstat (limited to 'prolog')
-rw-r--r-- | prolog/problems/lists/last_elem_2/common.py | 3 | ||||
-rw-r--r-- | prolog/problems/lists/last_elem_2/sl.py | 2 | ||||
-rw-r--r-- | prolog/problems/lists/memb_2/sl.py | 1 |
3 files changed, 5 insertions, 1 deletions
diff --git a/prolog/problems/lists/last_elem_2/common.py b/prolog/problems/lists/last_elem_2/common.py index 4014b13..8c08d61 100644 --- a/prolog/problems/lists/last_elem_2/common.py +++ b/prolog/problems/lists/last_elem_2/common.py @@ -80,7 +80,8 @@ def hint(code, aux_code): return [{'id': 'base_case'}] # target predicate seems to always be false - if not prolog.engine.ask_truthTO(engine_id, 'last_elem([_,_,_,_,_,_], _)'): + if not prolog.engine.ask_truthTO(engine_id, 'last_elem(_, _)') and \ + not prolog.engine.ask_truthTO(engine_id, 'last_elem([_,_,_,_,_,_], _)'): return [{'id': 'predicate_always_false'}] # base case works, the recursive doesn't (but it doesn't timeout) diff --git a/prolog/problems/lists/last_elem_2/sl.py b/prolog/problems/lists/last_elem_2/sl.py index 91ae527..c0d8082 100644 --- a/prolog/problems/lists/last_elem_2/sl.py +++ b/prolog/problems/lists/last_elem_2/sl.py @@ -64,5 +64,7 @@ in seznam dolžine ena (v tem vrstnem redu)? Seznam dolžine ena seveda zapišem <p>Znaš sedaj dobiti zadnji element s pomočjo <code>conc/3</code>? To bo že še prišlo prav. Seveda pa je dostop do zadnjega elementa še vedno potraten, O(n). Zato, če ni važno od kje ali kam dostopati, se splača vedno delati s prvim elementom.</p> +<p>Kaj pa naredi tole? ;)</p> +<p><code>?- conc([a,b,c], [q], L).</code></p> ''', } diff --git a/prolog/problems/lists/memb_2/sl.py b/prolog/problems/lists/memb_2/sl.py index 9668344..9a74fc8 100644 --- a/prolog/problems/lists/memb_2/sl.py +++ b/prolog/problems/lists/memb_2/sl.py @@ -18,6 +18,7 @@ plan = ['''\ <p>Kje se lahko skriva iskani element <code>X</code>? Spomni se, da ima seznam dva dela, glavo in rep. Torej sta možnosti dve! ;)</p> ''', '''\ +<p><img src="[%@resource base_case.svg%]" /></p> <p>Na seznam v prologu lahko gledamo kot na vrsto ljudi, ki vstopajo na avtobus. Šofer vidi samo prvega, ostali so skriti v repu seznama. Torej je iskani element <code>X</code> lahko prvi v vrsti ali pa...</p> ''', '''\ |