Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help me code this for python!! I have attached my code below as you will need it to complete the rest of the functions!!

image text in transcribedimage text in transcribed

please help me code this for python!! I have attached my code below as you will need it to complete the rest of the functions!! Thank alot!!!!

def make_empty_board(n): l=[] for i in range(n): l2=[] for j in range(n): l2.append(None) l.append(l2) return l def is_valid_location(loc, puzzle): dim = len(puzzle) x,y = loc if (x 1 : return True else: return False def get_row(puzzle,row_index): try: return puzzle[row_index] except Exception as e: return None

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

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

=+applying to all or most employers and employees?

Answered: 1 week ago

Question

=+associated with political parties and if so, which ones? Are

Answered: 1 week ago