Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CMT304

Programming Paradigms

2022

Task 1.1

Consider the problem of solving Hitori puzzles.  Hitori is played in an n x n grid of cells, where each cell contains a number j e {1, . . . , n}. The objective is to remove cells (marked as black), so that the three following rules are satisfied.

1.  No number appears more than once in a row or column.

2. The eliminated black cells cannot be horizontally or vertically adjacent.

3. The remaining numbered (white) cells must be connected to each other, i.e., any white cell is reachable from another white cell by vertical or horizontal movements through white cells.

You can nd an example of a  Hitori puzzle and a solution  in Wikipedia: https://en. wikipedia.org/wiki/Hitori

Write an ASP program (hitori .lp) that solves the puzzle for any instance. Your program will receive as input a set cell/3 of triples r, c, n such that the grid has number n in row r , column c. The output of your program is a set cellblack/2 of pairs r, c such that the cell at row r, column c is eliminated.

Document your code so the following is clear.

1. What the approach to solving the problem is.  In particular, you need to explain what

each rule achieves and how the rule achieves it.

Include your name and student id in the comments.

Task 1.2:

Write a short report on answer set programming related to the problem:

1.  Provide, in up to 300 words, two arguments for and two arguments against using answer set programming to solve this problem.

2.  Discuss, in up to 300 words, whether the logic programming paradigm is suitable for this problem or whether another paradigm of your choice is more appropriate, based on your previous arguments.

The word limits are an upper limit, not a target length.  Text longer than the word limit for each point may be ignored. Clearly mark each argument in your answer of the rst point and

indicate whether it is for or against. Only provide two arguments for and against; additional arguments will be ignored.

Criteria for assessment of Task 1

Task 1.1: maximum 50 marks, assessed according to the following scale:

Fail

0

No code has been submitted.

1 - 14

Code does not run or does not produce valid output for any valid input; little to no relevant documentation.

15 - 24

Code is valid without syntax errors and creates a valid output for every valid input (or produces a suitable error message for valid cases it cannot process). The output is not a solution, but a suitable attempt to solve the problem is visible. An attempt to document the code has been made.

Pass

25 - 29

Code is valid without syntax errors and creates a valid output for every valid input (or produces a suitable error message for valid cases it cannot process). A suitable attempt to solve the problem has been made, that will often produce the correct output. The attempt has been reasonably documented.

Merit

30 - 34

Code is valid without syntax errors and creates a valid output for every valid input (or produces a suitable error message for valid cases it cannot process). A suitable attempt to solve the problem has been made, that will nd the correct output. The attempt has been well documented, stating the idea to solve the problem and how it has been implemented.

Distinction

35 - 50

Code is valid without syntax errors and creates a valid output for every valid input. A suitable attempt to solve the problem has been made, that will nd the correct output for all problems, with excellent performance. The attempt has been well documented clearly stating the idea to solve the problem and how it has been implemented. It clearly shows an effort to properly use the main features of the logic programming paradigm.

Task 1.2: maximum 50 marks, assessed according to the following scale:

Fail

0

No document has been submitted.

1 - 14

An insufcient number of arguments has been submitted and/or they hardly apply to the logic programming paradigm. At most an incomplete attempt to discuss the suitability of the logic paradigm has been made.

15 - 24

An insufcient number of arguments has been submitted, but they show some understanding of the logic programming paradigm. An attempt has been made to discuss the suitability of the logic paradigm, but it hardly relates to the paradigm.

Pass

25 - 29

The required number of valid arguments has been submitted. They are generally valid for the logic programming paradigm, but they repeat simi- lar issues, do not consider the specic problem or contain mistakes in the details. A attempt has been made to discuss the suitability of the logic paradigm and some understanding of this paradigm is present.