Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Make two helper functions called empty() and find(). The empty() function will take in a 2D list and will return True if all values in
Make two helper functions called empty() and find(). The empty() function will take in a 2D list and will return True if all values in the 2D list are 0 and False otherwise. The find() function will take in a 2D list and a value to search for. If the value is found within the 2D list, return a list of length 2 containing the x and y indices of the position of said value. Otherwise, return [-1, -1]
1. Make two helper functions called empty) and find(). The empty() function will take in a 2D list and will return True if all values in the 2D list are 0 and False otherwise. The find() function will take in a 2D list and a value to search for. If the value is found within the 2D list, return a list of length 2 containing the x and y Indices of the position of said value. Othwise, return (-1, -1] [25 marks] Sample input: grid - [C23, 34, 67). [44, 5, 31. t7, 8, 9)) Sample output: empty (grid) -> False find(grid, 67)-> (0, 2) Sample input: grid - to, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0] Sample output: empty (grid) -> True find(grid, 69) -> (-1,-1]Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started