Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Many Hard LeetCode Problems Are Easy Constraint Problems (buttondown.com/hillelwayne)
6 points by tannhaeuser 8 months ago | hide | past | favorite | 3 comments


Here's an easy ad-hoc Prolog program for the first problem:

    % Given a set of coin denominations,
    % find the minimum number of coins
    % required to make change.
    % IE for USA coinage and 37 cents,
    % the minimum number is four
    % (quarter, dime, 2 pennies).
    num(0). num(1). num(2).
    num(3). num(4). num(5).
    ?- num(Q), num(D), num(P),
       37 is Q * 25 + D * 10 + P
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.

[1]: https://quantumprolog.sgml.net/browser-demo/browser-demo.htm...


Dynamic programming problems are trivialized by using a library that implements dynamic programming algorithms. So?


I get what you are saying, but this is not libraries that implement dynamic programming.

There are general libraries for dynamic programing that are interesitng, see for example https://didp.ai/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: