0

Questions are as follows:

Points on the straight line, 1, 2, 3, 4, 5, the starting point is 1, can go to any point, but a point can only be reached once, output the path to visit all points.

I learned that this problem was solved using recursion, but I don't know how to use recursion correctly in ASP. I hope someone can help me. I have been struggling for more than ten hours. Because there is very little information on logic programming, I don't know where to start looking for information.

point(1..5).

% start point
start(1).
jump(0, 1).
% possible_jump
% jump(N, X) Indicates that step N jumps to point X
possible_jump(N + 1, Y) :- point(Y), jump(N, X), X!=Y.

% CHOOSE JUMP
1 { jump(N, X) : possible_jump(N, X) } 1.


#show jump/2.
2
  • What tool are you using to write and test that code? Commented Nov 21, 2023 at 18:56
  • Can you further elaborate your question? Can you provide the expected result? Commented Nov 22, 2023 at 7:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.