Question: Functions on python help Functions on python unset_location(puzzle, loc): given a puzzle and a location (row, col), try to remove the value at that location

Functions on python help

Functions on python help Functions on python unset_location(puzzle, loc): given a puzzle

Functions on python unset_location(puzzle, loc): given a puzzle and a location (row, col), try to remove the value at that location (change to None). Return True if the puzzle was successfully changed (the value at that location is removed). Return False if the location is not valid, or there is currently no value at that location. unset_location ([[11], (0, 0)) rightarrow True # puzzle is now [[None]] unset_location ([[1]], (0, 1)) rightarrow False # location is invalid unset_location ([[None]], (0, 0)) rightarrow False # location is already None unset_location ([[1, 2], [1, 11], (1, 0)) rightarrow True # puzzle is now [[1, 2], [None, 1]] get size(puzzle): given a puzzle, return its size as an integer. You do not need to check whether the given puzzle is valid get_size([[None, None], [None, None]]) rightarrow 2 #2x2 puzzle get_size ([[1, 2, 3], [2, 1, 3], [None, None, 3]]) rightarrow 3 #3x3 puzzle get_size([[5]]) rightarrow 1 #1x1 puzzle get valid numbers (size): given a positive size, return a list of the numbers which can be validly placed in a puzzle of that size get_valid_numbers(2) rightarrow [1, 2] #2x2 puzzle get_valid_numbers(3) rightarrow [1, 2, 3] #3x3 puzzle get_valid_numbers (1) rightarrow [1] #1x1 puzzle contains only valid symbols(puzzle, complete): check if a puzzle contains only valid numbers. If the puzzle is incomplete, also allow None in the puzzle. complete will be a boolean indicating whether or not the puzzle is complete. You do not need to check that the puzzle is valid, only if the numbers used are correct. Contains_only_valid_symbols ([[1]], True) rightarrow True # contains 1 the only valid value contains_only_valid_symbols ([[None], True) rightarrow False # complete puzzle should not contain None contains only valid symbols ([[None]], False) rightarrow True # puzzle is incomplete so None is ok contains_only_valid_symbols ([[1, 1], [1, 1]], True rightarrow True # puzzle contains only valid values (1s and 2s) has repeat(xs, v): given a list of numbers xs and a number n, check whether xs has repeated values of n. Return True if v occurs more than once in xs, return False otherwise. You may not use .count ()! Has_repeat ([None], 1) rightarrow False has_repeat ([1, 2, 3], 1) rightarrow False has_repeat ([1, 2, 1], 1) rightarrow True get_row (puzzle, row index): return the row at the specified row_index from puzzle as a list. Return None if the row index is invalid get_row ([[1, None], [2, None 0) rightarrow [1, None] # row 0 get _row([[1, None], [2, None]], 1) rightarrow [2, None] # row 1 get_row ([[1, None], [2, None]], 2) rightarrow None # invalid index

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!