Hi, I have an assignment. I need to write code in logic programming language SWI-Prolog.
Its very hard and I am going to appreciate if you help me :D.
This is the assigment:
Print 2D array size of (width x height) in spiral order.
More explanation and example:
You have input, width and height that are integers.
With this input program needs to print a matrix "spiral" of numbers, from 1 to (height x width).
Height is size of column in "spiral" matrix
Width is size of row in "spiral" matrix
This is just an example:
spiralmatrix(w,h). /*w - width, h - height
Input:
?-spiralmatrix(5,4)
Output:
1 2 3 4 5
14 15 16 17 6
13 20 19 18 7
12 11 10 9 8
/* spacing in this matrix doesn't matter