Given an NxM matrix representing a garden, each entry contains a number, which is the number of carrots in that plot. A rabbit starts in the middle, or plot closest to middle with the most carrots and always goes up down left or right after eating to the plot with the most carrots. The values of the matrix will represent numbers of carrots available to the rabbit in each square of the garden. If the garden does not have an exact center, the rabbit should start in the square closest to the center with the highest carrot count.
On a given turn, the rabbit will eat the carrots available on the square that it is on, and then move up, down, left, or right, choosing the the square that has the most carrots.If there are no carrots left on any of the adjacent squares, 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.
Write a function which takes a garden matrix and returns the number of carrots the rabbit eats. You may
A line has formed to buy tickets for a concert. In order to delay a shortage caused by brokers buying large blocks of tickets, venue management has decided to sell only one ticket at a time. Buyers have to to wait through line again if they want to buy more tickets. Jesse is standing in line and has a number of tickets to purchase.
Given a list of ticket buyers with their numbers of desired tickets, determine how long it will take Jesse to purchase his tickets. Jesse's position in line will be stated, and each transaction takes 1 unit of time. For your purposes, no time is spent moving to the back of the line.