Question: Python 3 Coding: Here is the code I have finished for the other half of the project. This is relevant because some of the functions

Python 3 Coding:

Here is the code I have finished for the other half of the project. This is relevant because some of the functions build upon other defined functions:

def make_empty_board(n): l = [] for i in range(n): l2 = [] for k 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

def is_complete(puzzle): for x in range(len(puzzle)): for y in range(len(puzzle)): if puzzle[x][y] == None: return False return True

def get_value_at_location(puzzle, loc): x,y = loc return puzzle[x][y]

def set_location(puzzle, value, loc):

x,y = loc if is_valid_location(loc, puzzle) == True: puzzle[x][y] = value return True else: return False

def unset_location(puzzle, loc): if is_valid_location(loc, puzzle) == False: return False x,y = loc row = puzzle[x] element = row[y] if element == None: return False else: row[y] = None return True

def get_size(puzzle): count = 0 for row in puzzle: count += 1 return count

def get_valid_numbers(size): validList = [] for i in range(1, size + 1): validList.append(i) return validList

def contains_only_valid_symbols(puzzle, complete): size = get_size(puzzle) validList = get_valid_numbers(size) if complete == False: validList.append(None) for row in puzzle: for element in row: if element not in validList: return False return True

def has_repeat(xs, v): count = 0 for i in xs: if i == v: count += 1 if count > 1: return True else: return False

def get_row(puzzle, row_index): size = get_size(puzzle) if row_index + 1 > size: return None return puzzle[row_index]Python 3 Coding: Here is the code I have finished for theother half of the project. This is relevant because some of the

is valid cage solution(puzzle, op, expected total, locations given a puzzle, an operation o 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 Assumptions the puzzle is complete the operation will be one of: or X subtraction operations will always involve two (and only two) locations subtraction operations pass in the absolute value of the operation (see examples) the locations will be valid and in a list in the form (row, col), (row, col) (row, col)] Examples is valid cage solution 1] 0,0) True location (0, sums to 1 is valid cage solution 1,2 2,1 1, 0,0 (1,0 True the absolute value of location (0,0) location (1,0) is 1. is valid cage solution 1,2 2,1 1,0), (0,0)]) True location the absolute value of location (1,0) (0,0) is 1 is valid cage solution 1,2 2,1 'x' 0,0), (0,1 1,0 (1,1)]) True all values in the puzzle multiplied together is valid cage solution 1,1],[1,1 0,0)]) True location (0,0) multiplies to 1. is valid cage solution 1,2 2,1 [(0,0),(0,1)1) False location (0,0) and (0,1) do not sum to 4 is valid (puzzle, cages, complete determine if the given puzzle is currently in a valid state: if incomplete, check whether all rows/columns are valid, if complete also check cages and determine if the puzzle locations total correctly for the operation. (HINT: use has valid rows(), has alid cols(), and is valid cage solution(). board 1 [[3,1,2],[2,3,11, 2, board 2 [[3,1,2],[2,2,1],[1, 2, is valid(board 1 False True is valid(board 1 0,0 1,0 True True is valid(board 1 True) False not valid cage 0,0 1,0 is valid(board 2 0,0 1,0 111, True False invalid row is valid None, None None, None ,5 0,0 1,0)] False True get board string(puzzle): return a string representation of a puzzle which, when printed, would display a ascii art version of the puzzle. You may assume a puzzle of size 9x9 or smaller for this method only. Example For the puzzle [3,1,2],[2, None, None the string would be None, None ,None Which printed would display as: [e] [1] [2] [e] [1] [2] Notes: (a) Columns are three characters wide (a space, a number, and a space) with a dividers (I) (b) For the dashed lines we need just enough to cover the top and bottom of the puzzle, no matter what size the puzzle is (one dash to start, then four dashes per column). To make the dashes appear in the correct place, there are also four spaces to the left. (c)The column headers (IO], [1], etc.) are centered on the columns and the row headers (10], [1], etc.) have a single space between them and the first There are no leading spaces for the row headers

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!