Here [1] is my solution, it passes the benchmarks but i haven't tried to prove it correct. Computing the solutions is instantaneous on my machine, even in ghci, including f k for h = h3. [1] https://github.com/Saizan/snippets/blob/master/Search.hs - Andrea