Sale!

# Assignment 03- Haskell functions in Greater Than Sudoku

\$29.99

Category:

Contents
List of Figures
1 Instructions
In this assignment, you will be required to write Haskell functions that simplify playing of the variation of Greater Than Sudoku.
1.1 Data File Speciﬁcation
An example of properly formatted ﬁle is shown in Figure 1. The ﬁle encodes a tuple containing list of spaces to place values into, the values to be placed in the corresponding spaces, the visible grid, the inequalities between the rows (−1 means decreasing from top to bottom, 1 means increasing from top to bottom), and the inequalities between the columns (−1 means decreasing from left to right, 1 means increasing from left to right).
1
part01test01.gts
( [16,8,6,9,14,13,3,10,14,7,6,5], [2,4,1,1,3,3,3,1,4,3,3,1], [ “4—“, “3—“, “–24”, “2-3-” ], [ [-1,-1,1,-1], [-1,1,-1,1], [1,1,1,-1] ], [ [-1,-1,1], [-1,1,-1], [1,-1,1], [1,-1,-1] ] )
Figure 1: A properly formatted game encoding
Spaces are deﬁned from the upper-left corner of the game (Position 1), down the ﬁrst column, down the second column…to the bottom of the last column.
1.2 csce322hw03pt(num).hs
This assignment requires the implementation of two (2) methods: onePlayerOneMove and onePlayerManyMoves . Each method will be implemented in its own ﬁle (named csce322hw03pt(num).hs, where (num) is 01 or 02). The behavior of each function is described below.
1.2.1 onePlayerOneMove (csce322hw03pt01.hs)
onePlayerOneMove :: [[Char]] – Int – Int – [[Char]] This method will take a move to make and a game, and return a game after the move according to the following rules:
1. If the space is already full, no change is made to the game
2. If the move would violate a rule immediately (including a 1 to the left of a sign or a numRows to the left of a < sign), no change is made to the game
3. The value is placed in the correspond space, otherwise.
Page 2
( [16,8,6,9,14,13,3,10,14,7,6,5], [2,4,1,1,3,3,3,1,4,3,3,1], [ “4—“, “3—“, “–24”, “2-3-” ], [ [-1,-1,1,-1], [-1,1,-1,1], [1,1,1,-1] ], [ [-1,-1,1], [-1,1,-1], [1,-1,1], [1,-1,-1] ] )
Figure 2: Game State Before onePlayerOneMove
“Result” “4—” “3—” “–24” “2-3-” “”
Figure 3: Game State After onePlayerOneMove
Sample Sequence
1.2.2 onePlayerManyMoves (csce322hw03pt02.hs)
onePlayerManyMoves :: [[Char]] – [Int] – [Int] – [[Char]] This method will take moves to make and a game, and return a game. If a move is invalid, it is skipped and the next move is attempted. The same rules as onePlayerOneMove apply.
Page 3
( [16,8], [2,4], [ “4—“, “3—“, “–24”, “2-3-” ], [ [-1,-1,1,-1], [-1,1,-1,1], [1,1,1,-1] ], [ [-1,-1,1], [-1,1,-1], [1,-1,1], [1,-1,-1] ] )
Figure 4: Game State Before onePlayerManyMoves
“Result” “4—” “3—” “–24” “243-” “”
Figure 5: Game State After onePlayerManyMoves
Sample Sequence
2 Naming Conventions
You will be submitting at least 2 .hs ﬁles (csce322hw03pt01.hs and csce322hw03pt02.hs). If you do not submit a modiﬁed Helpers.hs ﬁle, the default one will be provided.