Consider the problem of solving a 2 2 Sudoku puzzle. It is played on a grid consisting of
44 cells subdivided into four 22 squares as shown in the ﬁgure below. Some of the cells
are empty, some of them are ﬁlled with digits from 1 through 4. The aim is to ﬁll in the empty
cells such that every row, every column, and every 22 square contains the digits 1, 2, 3, 4.
Write an efﬁcient Haskell function that can solve this problem. Its input is a matrix, repre-
sented as a list of rows, where each row is a list of the numbers in the grid. The numbers
are either 1, 2, 3, 4 if the ﬁeld is ﬁlled or 0 if the ﬁeld is empty. The output of the function
should be one solution to the problem, in the same matrix format with the 0 values replaced
by a number 1 to 4 (or an error message if the input has no valid solution). For example, for
the above grid, the input is
input = [[3,4,0,0],
and one solution is
output = [[3,4,2,1],
Make sure you clearly document your approach and how to use your function in the com-
ments. Note that you must write your own code to solve this problem and not just call a
library function to solve such problems. You may use the standard libraries listed in the
Haskell 2010 language report, but not any other libraries.
Task 2: Write a short report on logic vs. functional programming related to the problem:
1. Provide, in up to 300 words, two arguments for and two arguments against using
functional programming to solve the problem.
2. Discuss, in up to 300 words, whether the functional 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 will 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.
本网站支持 Alipay WeChatPay PayPal等支付方式
E-mail: firstname.lastname@example.org 微信号:vipnxx