Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python question Sudoku Task 1: Inference Inference is the process of deriving a logical conclusion from a set of given facts. In the context of

python question

image text in transcribed

Sudoku Task 1: Inference Inference is the process of deriving a logical conclusion from a set of given facts. In the context of Sudoku, a player attempts to infer the correct values for empty fields given the content of the already filled fields. There are numerous inference rules that experienced Sudoku players use. Let us focus on the 'Singles' strategy (http://www. taupierbw.be/SudokuCoach/SC_Singles.shtml), which contains two separate rules. 1. The first one (let us refer to it as forward single") is the simple observation that if an empty field f has only one available option x, then f should contain x. 2. The second single rule (let us refer to it as "backward single") is based on the fact that in every region of a Sudoku board (i.e., row, column, and subgrid) the solution needs to contain every number from 1 to n. From this we can derive the rule as: if within a given region the number x is available as option only in one field f of that region, then the solution contains x in field f (because it is the only field that can supply"). It turns out that both rules in conjunction are enough to solve a lot of Sudoku boards and we can implement a decent partial Sudoku solver based on them. Write a function inferred (board) that accepts as input a Sudoku board and returns as output a new Sudoku board that contains all values that can be inferred by repeated application of the two single rules. For example, for the big game board above the function would completely solve the board: >>> inferred(big) [[2, 1, 3, 4, 5, 6, 7, 8, 9], [4, 5, 6, 7, 8, 9, 1, 2, 3], [7, 8, 9, 1, 2, 3, 4, 5, 6], [1, 2, 4, 3, 6, 5, 8, 9, 7], (3, 6, 5, 8, 9, 7, 2, 1, 4], [8, 9, 7, 2, 1, 4, 3, 6, 5], [5, 3, 1, 6, 4, 2, 9, 7, 8], [6, 4, 2, 9, 7, 8, 5, 3, 1], [9, 7, 8, 5, 3, 1, 6, 4, 2]] In contrast, for the big4 game board, our inference rules get stuck right in the beginning: >>> inferred(big) [[0, 0, 0,6, 0, 0, 2, 0, 0], [8, 0, 4, 2, 3, 0, 0, 0, 0] [0, 0, 0, 0, 0, 9, 0, 0, 0], [4, 0,5, 0, 0, 0, 0, 0, 7] [7, 1, 0, 0, 0, 0, 0, 0, 0 0, 0, 3, 0,5, 0, 0, 0, 8 (3, 0, 0, 0, 7, 0, 0, 0,4 [0, 0, 0, 0, 0, 1, 9, 0, 0 10, 0, 0, 2, 0, 0, 0, 6, oj] Finally, integrate this function into the play function such that on user input 'i' (or 'infer"), the current board state is replaced by the inferred board state and as usually the new state is printed to the console to be inspected by the user). For that, make sure that the inferred function does not modify the input board. 3 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Explain the difference between opportunities and ideas.

Answered: 1 week ago

Question

Mention the bases on which consumer market can be segmented.

Answered: 1 week ago

Question

Explain consumer behaviour.

Answered: 1 week ago

Question

Explain the factors influencing consumer behaviour.

Answered: 1 week ago