▲ | tannhaeuser 4 days ago | |
Here's an easy ad-hoc Prolog program for the first problem:
You can just paste it into [1] to execute in the browser. Using 60 as target sum is more interesting as you can enumerate over two solutions.(Posting again what I already posted two days ago [2] here) [1]: https://quantumprolog.sgml.net/browser-demo/browser-demo.htm... | ||
▲ | 6gvONxR4sf7o 4 days ago | parent | next [-] | |
Of course, the challenge is that the next question after solving a leetcode problem is often to explain and optimize the performance characteristics, which in prolog can get stupidly hairy. | ||
▲ | skydhash 4 days ago | parent | prev [-] | |
I've actually used pseudo-prolog to explain how to solve leetcode problems to a friend. Write the facts, then write the constraints, and then state your problem. Close to the last part, they've already understood how to solve it, or at least how to write the program that can answer the question. |