Answered step by step
Verified Expert Solution
Link Copied!

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 2D 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 (i.e., 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 10% 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

Students also viewed these Databases questions

Question

Acceptance of the key role of people in this process of adaptation.

Answered: 1 week ago

Question

preference for well defined job functions;

Answered: 1 week ago