Answered step by step
Verified Expert Solution
Question
1 Approved Answer
c sharp - This is a real interview question. In other words, it is your time to explore and feel what to expect in a
c sharp This is a real interview question. In other words, it is your time to explore and feel what to expect in a job interview. For this question, you have a garden that is represented by a D array, and we are placing a hungry rabbit in the middle of the garden. The values of the array represent the carrot count that is available for the rabbit in each square within the garden. In case the garden does not have an exact center, the rabbit begins in the square that is closest to the center with the highest carrot count.
On a given turn, the rabbit will eat the carrots that are available on the square he is on then the rabbit moves up down, left, or right choosing the square that has the highest number of carrots. If there are no carrots left on any of the adjacent squares ie up down, left, or right the rabbit will go to sleep. You may assume that the rabbit will never have to choose between two squares with the same number of carrots.
Your program must have a function that takes a garden matrix and returns the total number of carrots the rabbit eats. The matrix cannot be populated with negative integers. As a note, you must have the array within your program. In other words, the program should not ask the user to input an array.
You must test your program with the following array. You will lose of your score if you dont test the program with the following array.
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