Question: Arrange three 1 s , three 2 s , . . . , three 9 s in a list ( which therefore will consist of

Arrange three 1s, three 2s,..., three 9s in a list (which therefore will consist of 27 numbers)...
... such that, for each i belongs to [1,9], there are exactly i numbers between two successive occurrences (in the list) numbered i.
Therefore, for example, 1,2,1,8,2,4,6,2 could be a part of the final solution, while 1,2,1,8,2,4,2,6 could not.
Solve the problem using SWI-Prolog, Create the Knowledge Base. Please test the two examples above and show the input and output. The first example "1,2,1,8,2,4,6,2" should be true but the second example "1,2,1,8,2,4,2,6" should be false.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!