Skip to content

Instantly share code, notes, and snippets.

@hwayne
Created October 1, 2023 21:05
Show Gist options
  • Save hwayne/951a8c148f6f26fb23fbe892442be28b to your computer and use it in GitHub Desktop.
Save hwayne/951a8c148f6f26fb23fbe892442be28b to your computer and use it in GitHub Desktop.
Sum finder
import planner.
main =>
S0 = {22, 0, [6, 6, 9, 5, 9, 1, 10, 9, 9, 3]},
plan(S0, Plan),
nl,
writeln(Plan),
nl.
final({Target, Current, _}) =>
Target = Current.
action(S0, S1, Action, ActionCost) =>
Action = {add, X, Next},
ActionCost = 1,
S0 = {Target, Current, L},
member(X, L),
Next = Current + X,
not member(Next, [12, 21]),
S1 = {Target, Next, delete(L, X)},
true.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment