Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

PYTHON PLEASEimage 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

Recommended Textbook for

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions

Question

Have ground rules been established for the team?

Answered: 1 week ago

Question

a. How are members selected to join the team?

Answered: 1 week ago

Question

b. Will new members be welcomed?

Answered: 1 week ago