Question: Python 3 Functions Coding: Below are the functions required to complete the last pages of functions def get_valid_numbers(size): validList = [] for i in range(1,
Python 3 Functions Coding: Below are the functions required to complete the last pages of functions
def get_valid_numbers(size): validList = [] for i in range(1, size + 1): validList.append(i) return validList
def get_row(puzzle, row_index): size = get_size(puzzle) if row_index + 1 > size: return None return puzzle[row_index]
def has_repeat(xs, v): count = 0 for i in xs: if i == v: count += 1 if count > 1: return True else: return False

![last pages of functions def get_valid_numbers(size): validList = [] for i in](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3c9d8221b6_95166f3c9d76ff3e.jpg)
complete): given a puzzle, determine if the row at row index is a is valid row(puzzle row index 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. (HINT use get valid numbers get row() and has repeat [2,4,None ,None 1,[1, 2,3,3],[3,1 ,None,5],[4,3 ,None, None board is valid row (board, 0, False) True ok to have None if incomplete is valid row (board, 0 True) False cannot have None if complete is valid row (board, 1, True False two 3s in same ro is valid row(board, 2 False) False invalid value 5 is valid row(board, 2, True False not even a valid ro complete): determine if all the rows in puzzle are valid. complete is a boolean has valid rows (puzzle indicating if the rows should not contain None values. If incomplete allow None, if complete, do not allow None. (HINT: use get row() and is valid row() as part of your solution) has valid rows [1, 2],[1,21], True True has valid rows ([[1, None],[1,21], False) True has valid rows ([[1,None 1,[1, 211, True False cannot have None if complete has valid rows([[1,4],[ 1,211, True) False row 0 has a 4 in a 2x2 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,Nonell, 0) [1 col 0 get column ([[1,None 1,[2,None 11, 1) [None, None] col 1 get column ([[1,None 1,[2,None] 1, 2) invalid index None complete) similar to is valid row but checking the validity of is valid col (puzzle col index specified column instead. (HINT: use get valid numbers get column and has repeat().) [2,1,None ,None ],[None, 2,3,3],[3, 1, None,5],[4,3,None,None board is valid col(board, 0, False) True ok to have None if incomplete is valid col (board, 0, True) False cannot have None if complete is valid col board, 1 True) False two 1s in same column is valid col(board, 3, False) False invalid value 5 is valid col(board, 7 True False not even a valid column complete): determine if all the columns in puzzle are valid. complete is a has valid cols (puzzle boolean indicating if the columns may contain None values. If incomplete allow None, if complete, do not allow None. (HINT use is valid col() and get column() as part of your solution) has valid cols ([[1,2],[1,1]], True) False two 1s in col 0 has valid cols([[1,None],[2,11], False) True has valid None ],[2,111, True) False cannot have None if complete has valid cols([[1,4],[2,11], False col 1 has a 4 in a 2x2 puzzle True complete): given a puzzle, determine if the row at row index is a is valid row(puzzle row index 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. (HINT use get valid numbers get row() and has repeat [2,4,None ,None 1,[1, 2,3,3],[3,1 ,None,5],[4,3 ,None, None board is valid row (board, 0, False) True ok to have None if incomplete is valid row (board, 0 True) False cannot have None if complete is valid row (board, 1, True False two 3s in same ro is valid row(board, 2 False) False invalid value 5 is valid row(board, 2, True False not even a valid ro complete): determine if all the rows in puzzle are valid. complete is a boolean has valid rows (puzzle indicating if the rows should not contain None values. If incomplete allow None, if complete, do not allow None. (HINT: use get row() and is valid row() as part of your solution) has valid rows [1, 2],[1,21], True True has valid rows ([[1, None],[1,21], False) True has valid rows ([[1,None 1,[1, 211, True False cannot have None if complete has valid rows([[1,4],[ 1,211, True) False row 0 has a 4 in a 2x2 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,Nonell, 0) [1 col 0 get column ([[1,None 1,[2,None 11, 1) [None, None] col 1 get column ([[1,None 1,[2,None] 1, 2) invalid index None complete) similar to is valid row but checking the validity of is valid col (puzzle col index specified column instead. (HINT: use get valid numbers get column and has repeat().) [2,1,None ,None ],[None, 2,3,3],[3, 1, None,5],[4,3,None,None board is valid col(board, 0, False) True ok to have None if incomplete is valid col (board, 0, True) False cannot have None if complete is valid col board, 1 True) False two 1s in same column is valid col(board, 3, False) False invalid value 5 is valid col(board, 7 True False not even a valid column complete): determine if all the columns in puzzle are valid. complete is a has valid cols (puzzle boolean indicating if the columns may contain None values. If incomplete allow None, if complete, do not allow None. (HINT use is valid col() and get column() as part of your solution) has valid cols ([[1,2],[1,1]], True) False two 1s in col 0 has valid cols([[1,None],[2,11], False) True has valid None ],[2,111, True) False cannot have None if complete has valid cols([[1,4],[2,11], False col 1 has a 4 in a 2x2 puzzle True
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
