Question: I need help on these 3 functions: PYTHON 3 is-valid cage solution(puzzle, op, expected total locations given a puzzle, an operation op an integer expected
I need help on these 3 functions: PYTHON 3


is-valid cage solution(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. Assumptions o the puzzle is complete o the operation will be one of: or 'x' o subtraction operations will always involve two (and only two) locations o subtraction operations pass in the absolute value ofthe operation (see examples) the locations will be valid and in a list in the form [(row, col), (row, col), row, col Examples o is valid cage solution([[1]] 1, (0,0)]) True location (0,0) sums to 1 o 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 o is valid cage solution([[1,2],[2,1]], 1, [(1,0), (0,0)]) True the absolute value of location (1,0) location (0,0) is 1 a is valid cage solution ([[1,2],[2,1]] 'x', 4, [(0,0), (0,1), (1,0), (1,1)]) True all values in the puzzle multiplied together is valid cage solution([[1,1],[1,1]] 1, (0,0)]) True location (0,0) multiplies to 1 is valid cage solution([[1,2],[2,1]] 4, [(0,0), (0,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 valid cols(), and is valid cage solution() board 1 [[3,1,2],[2,3,1],[1,2,31] board 2 [[3,1,2],[2, 2,1],[1, 2, 3]] o is valid (board 1, False) o is valid (board 1, ',5, [(0,0), (1,0)]] True) True a is valid (board 1, CC' 4,[(0,0) (1,0)]] True) False not valid cage invalid row o is valid (board 2, 5,[(0,0), (1,0)]]], True) False o is valid ([[None, None [None, None [C'+",s, (1,0)]]], alse) True 5,[(0,0)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
