Answer to Question #171910 in Prolog for umair

Question #171910

You are to write a simple program in Prolog to find a path through a maze. Your input will consist of facts of the form

    pway(a, b, 10).

indicating that there is a passageway from intersection a to intersection b of length 10 meters. You are to write a rule

    solve(X, Y, P, N) :- ...

that will find a path P of length N (if one exists) from intersection X to intersection Y. The intent is that the user will invoke solve as a query, specifying X and Y as constants and P and N as variables.

Here is a concrete example. Suppose the database contains the following rules:

    pway(a, b, 10).
    pway(b, c, 15).
    pway(d, c, 5).
    pway(d, b, 10).

If the user types

    solve(a, d, P, N)

the Prolog interpreter might respond with

    P = [a, b, c, d]
    N = 30
1
Expert's answer
2022-01-19T10:31:06-0500
Dear umair, your question requires a lot of work, which neither of our experts is ready to perform for free. We advise you to convert it to a fully qualified order and we will try to help you. Please click the link below to proceed: Submit order

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS