Questions: 69

Answers by our Experts: 50

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!

Search & Filtering

There are 5 ships in a port:

1. The Greek ship leaves at six and carries coffee.
2. The Ship in the middle has a black chimney.
3. The English ship leaves at nine.
4. The French ship with blue chimney is to the left of a ship that carries coffee.
5. To the right of the ship carrying cocoa is a ship going to Marseille.
6. The Brazilian ship is heading for Manila.
7. Next to the ship carrying rice is a ship with a green chimney.
8. A ship going to Genoa leaves at five.
9. The Spanish ship leaves at seven and is to the right of the ship going to Marseille.
10. The ship with a red chimney goes to Hamburg.
11. Next to the ship leaving at seven is a ship with a white chimney.
12. The ship on the border carries corn.
13. The ship with a black chimney leaves at eight.
14. The ship carrying corn is anchored next to the ship carrying rice.
15. The ship to Hamburg leaves at six.

Which ship goes to Port Said? Which ship carries tea?
In this assignment, you are expected to implement a solution in Prolog to the N-Tiles Problem.N-Tiles
problem is problem of placing N copies of a tile T (TX/TY) on an SxS square grid so that no two copies
touch each other. Namely, N-Tiles problem takes three inputs:
• S: Grid Size
• N: Number of copies to place
• T : Tile definition in (TX,TY) form.
and produces an N-sized set of points on the grid satisfying the non-touching condition.

A call to ntiles predicate should fail if there exists no solution for the problem specified with parameters.
Below is given examples for a no-solution case and a case with 4 different solutions.
>ntiles(2/1,3,3,P).
No

>ntiles(2/1,3,2,P).
P=[1/1,1/3]?;
P=[1/1,2/3]?;
P=[2/1,1/3]?;
P=[2/1,2/3]?;
No.
Which one of the following prolog
programs correctly implement “if G
succeeds then execute goal P else
execute goal θ ?”
(A) if-else (G, P, θ) :- !, call(G), call(P).
if-else (G, P, θ) :- call(θ).
(B) if-else (G, P, θ) :- call(G), !, call(P).
if-else (G, P, θ) :- call(θ).
(C) if-else (G, P, θ) :- call(G), call(P), !.
if-else (G, P, θ) :- call(θ).
(D) All of the above
I have to create a heuristic algorithm where it searches through a list of places and determines the best way to navigate from a - b by the shortest distance sorting the list into order of place & distance and displaying that list without duplicates.

I have already wrote some Prolog code where it displays the place and distance but now I need to remove the duplicates. Can anyone help?
https://www.dropbox.com/s/wptinvfbg2nucoc/Assignment01.pdf
% Process guess takes a list of codes representing the answer, a list of codes representing the current
% "display phrase" with blanks in it, and the code of the letter that was just guessed. If the guess
% was right, call substitute to put the letter in the display phrase and check for a win. Otherwise, just
% get another guess from the user.

processGuess(AnsList,BlankList,GuessName, CountFailed):-
member(GuessName,AnsList),
!,
write('Correct!'),
nl,
substitute(AnsList, BlankList, GuessName, NewBlanks),
checkWin(AnsList,NewBlanks, CountFailed).

processGuess(AnsList, BlankList, _, CountFailed) :-
( CountFailed == 5
-> format('Sorry, game over. You didn\'t guess (~s)~n', [AnsList])
; write('Wrong Try Again!'),
nl,
CountFailed1 is CountFailed + 1,
getGuess(AnsList, BlankList, CountFailed1)
).
The main idea is to make a list where i will put all the wrong letters the user gave and check it everytime he gives another wrong letter
The objective of this project is to build a Prolog program that can transform
Well-formed formulas (fbf) of a first order logical language to normal form (conjunctive
cnf or normal form).

To properly handle the existential variables we introduce a new rewrite rules,
Skolemizzazione said:

exist(X, p(X)) -> p(sk00042)

Note how sk00042 'and a constant and not variable. Note also that this operation 'and realt'a
pi'u complicated in the presence of variables universally quantified.

every(Y, exist(X, p(X, Y))) -> every(Y, p(sf666(Y), Y))

A variable existential can be replaced by a function (called Skolem) which is applied
variables pi'u universal "external".

You'll need the following code to manage the operation of Skolemization:

skolem_variable(V, SK) :- var(V), gensym(skv, SK).
skolem_function([], SF) :- skolem_var(_, SF).
skolem_function([A | ARGS], SF) :-
gensym(skf, SF_op),
SF =.. [SF_op, A | ARGS].
1. Using Prolog as the programming language for LOGIC, construct the relevant command to do the following tasks:-


a. Prolog Lists - A list is either empty or it is composed of a first element (head) and a tail, which is a list itself. In Prolog we represent the empty list by the atom [] and a non-empty list by a term [H|T] where H denotes the head and T denotes the tail.
(NOTE:- Given list MySenarai= [a,b,c,d,e,f, g, h] for the tasks listed below)

i. Find the last element of a list.
?-
Output:-

ii. Find the K'th element of a list. (K=5)
?-
Output:-

iii. Eliminate consecutive duplicates of list elements.
?-
Output:-

iv. Find the number of elements of a list.
?-
Output:-





v. Reverse a list.
?-
Output:-

vi. Find out whether a list is a palindrome.
?-
Output:-
vii. Duplicate the elements of a list.
?-
Output:-

viii. Drop every N'th element from a list. (N=3)
?-
Output:-

ix. Insert an element at a given position into a list. (element = zzz)
?-
Output:-

x. Extract a slice from a list. (I = 2; k = 5)
Given two indices, I and K, the slice is the list containing the elements between the I'th and K'th element of the original list (both limits included). Start counting the elements with 1
?-
Output:-
overground(newcrossgate,brockley,2).
overground(brockley,honoroakpark,3).
overground(honoroakpark,foresthill,3).
overground(foresthill,sydenham,2).
overground(sydenham,pengewest,3).
Write a rule that displays all of the stations that are within reach from a specified station given a time. e.g. what stations are reachable from Richmond in 15 minutes?
I am doing a Prolog assignment based on the London Overground. I have to create a rule that calculates how long a journey takes between two stations, from the answer provided in a previous query. eg(southkenton,kenton). Any Ideas on how I can start the rule of, and how I should structure it.
LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS