From bbcb29a202436fc0e222e187f1fadf0b1f305465 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sun, 22 May 2016 17:48:30 +0200 Subject: Prolog: update denotational_semantics problems --- .../denotational_semantics/prog_8puzzle_3/en.py | 31 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'prolog/problems/denotational_semantics/prog_8puzzle_3/en.py') diff --git a/prolog/problems/denotational_semantics/prog_8puzzle_3/en.py b/prolog/problems/denotational_semantics/prog_8puzzle_3/en.py index 51aa81a..7a94c74 100644 --- a/prolog/problems/denotational_semantics/prog_8puzzle_3/en.py +++ b/prolog/problems/denotational_semantics/prog_8puzzle_3/en.py @@ -2,17 +2,38 @@ name = 'prog_8puzzle/3' slug = '8-puzzle-solving language with semantics' description = '''\ -

Write a DCG for solving 8-puzzles. The syntax for this language should be the same as in the previous exercise: the first symbol in every word is [begin], followed by any sequence of "instruction" symbols from the set {left, right, up, down}, and finally [end]. The starting symbol should be named prog_8puzzle.

+

+Write a DCG for solving 8-puzzles. The syntax for this language should be the +same as in the previous exercise: the first symbol in every word is +[begin], followed by any sequence of "instruction" symbols from +the set {left, right, up, +down}, and finally [end]. The starting symbol should +be named prog_8puzzle. +

-

The meaning of a word (program) in this language has the form In-->Out, mapping from input to output states. Each state is a (permuted) list of numbers from 0 to 8, where 0 stands for the empty square and other numbers for the corresponding tiles. The first three numbers in the list correspond to the top row of the 8-puzzle, the next three numbers to the middle row, and the last three numbers to the last row. The meaning of instructions left, right, up and down is to move the blank tile in the given direction.

+

+The meaning of a word (program) in this language has the form +In-->Out, mapping from input to output states. Each state is a +(permuted) list of numbers from 0 to 8, where 0 stands for the empty square and +other numbers for the corresponding tiles. The first three numbers in the list +correspond to the top row of the 8-puzzle, the next three numbers to the middle +row, and the last three numbers to the last row. The meaning of instructions +left, right, up and down is +to move the blank tile in the given direction. +

 ?- prog_8puzzle([0,1,2,3,4,5,6,7,8]-->Out, [begin,down,right,end], []).
   Out = [3,1,2,4,0,5,6,7,8].
 
-

Helper predicates (already defined):
-  findblank(List,I) returns the 1-based index I of the element 0 in List
-  swap(List,I,J,NewList) creates NewList by swapping elements I and J in List

''' +

+Helper predicates (already defined): +

+ +''' hint = {} -- cgit v1.2.1