Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help on these functions. PYTHON3 Is_valid_row(puzzle, row_index, complete): given a puzzle, determine if the row at row_index is a valid set of numbers(containing
I need help on these functions. PYTHON3
Is_valid_row(puzzle, row_index, complete): given a puzzle, determine if the row at row_index is a valid set of numbers(containing only valid values and unique values). complete is a boolean indicating if the row may contain None values. As before, if the puzzle is incomplete, also allow None, if it is complete, do not allow None. Also note that it is OK to have multiple None values in one row. board = [[2, 4, None, None], [1, 2, 3, 3], [3, 1, None, 5], [4, 3, None, None]] is_valid_row(board, theta, False) Rightarrow True # ok to have None if incomplete is_valid_row(board, theta, True) Rightarrow False # cannot have None if complete is_valid_row(board, 1, True) Rightarrow False # two 3s in same row is_valid_row(board, 2, False) Rightarrow False # invalid value 5 is_valid_row(board, -2, True) Rightarrow False # not even a valid row has_valid_rows (puzzle, complete): determine if all the rows in puzzle are valid. complete is a boolean indicating if the rows should not contain None values. If incomplete allow None complete, do not allow None. Has_valid_rows ([[1, 2], [1, 2]], True) Rightarrow True has_valid_rows ([[1, None], [1, 2]], False) Rightarrow True has_valid_rows ([[1, None], [1, 2]], True) Rightarrow False # cannot have None if complete has_valid_rows ([[1, 4], [1, 2]], True) Rightarrow False # row theta has a 4 in a 2 times 2 puzzle get_column(puzzle, col_index): return the column with specified col_index from puzzle as a list. Return None if col_index is invalid. Get_column ([[1, None], [2, None]], theta) Rightarrow [1, 2] # col theta get column ([[1, none], [2, none]], 1) Rightarrow None # invalid index is_valid_col(puzzle, col_index, complete):similar to is_valid_row but checking the validity of specified column instead. board = [[2, 1, None, None], [None, 2, 3, 3], [3, 1, None, 5], [4, 3, None, None]] is_valid_col(board, theta, False) Rightarrow True # ok to have None if incomplete is_valid col(board, theta, True) Rightarrow False # cannot have None if complete is_valid_col (board, 1, True) Rightarrow False # two 1s in same column is_valid_col (board, 3, False) Rightarrow False # invalid value 5 is_valid_col (board, 7, True) Rightarrow False # not even a valid column has_valid_cols(puzzle, complete): determine if all the columns in puzzle are valid. complete is a boolean indicating if the columns may contain None values. If incomplete allow None, if complete, do not allow None. Has_valid_cols([[1, 2], [1, .1]], True) Rightarrow False # two 1s in col theta has_valid_cols ([[1, None], [2, 1]], False) Rightarrow True has_valid_cols([[1, None], [2, 1]], True) Rightarrow False # cannot have None if complete has_valid_cols ([[1, 4], [2, 1]], True) Rightarrow False #col 1 has a 4 in a 2 times 2 puzzle is_valid_cage_olution(puzzle, op, expected_total, locations): given a puzzle, an operation op, an integer expected_total, and a list of location tuples (e.g. a "cage" in a KenkKen puzzle), determine if the puzzle locations total correctly for the operation. You do not need to check if the rows/columns of the puzzle are valid
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started