## Mr K marsh

Mr K has a rectangular plot of land which may have marshes where fenceposts cannot be set. He wants you to find the perimeter of the largest rectangular fence that can be built on this land. For example, in the following m*n = 4*4 grid, x marks a marsh and . marks good land. .... ..x. ..x. x... If we number the rows and columns starting with 1, we see that there are two main areas that can be fenced: (1,1)-(3,2) and (1,2)-(4,4). The longest perimeter is 10. Function Description

View Solution →## Save the Prisoner!

A jail has a number of prisoners and a number of treats to pass out to them. Their jailer decides the fairest way to divide the treats is to seat the prisoners around a circular table in sequentially numbered chairs. A chair number will be drawn from a hat. Beginning with the prisoner in that chair, one candy will be handed to each prisoner sequentially around the table until all have been distributed. The jailer is playing a little joke, though. The last piece of candy looks like all the oth

View Solution →## Circular Array Rotation

John Watson knows of an operation called a right circular rotation on an array of integers. One rotation operation moves the last array element to the first position and shifts all remaining elements right one. To test Sherlock's abilities, Watson provides Sherlock with an array of integers. Sherlock is to perform the rotation operation a number of times then determine the value of the element at a given position. For each array, perform a number of right circular rotations and return the val

View Solution →## Sequence Equation

Given a sequence of n integers, p(1), p(2),......, P(n) where each element is distinct and satisfies 1 <= p(x) <= n. For each x where 1<= x <= n, that is x increments from 1 to n, find any integer y such that p(p(y)) = x and keep a history of the values of u in a return array. Example p = [5, 2, 1, 3, 4] Each value of x between 1 and 5, the length of the sequence, is analyzed as follows: 1. x = 1 = p[3], p[4] = 3, so p[p[4]] = 1 2. x = 2 = p[2], p[2] = 2, so p[p[2]] = 2 3. x =

View Solution →## Jumping on the Clouds: Revisited

A child is playing a cloud hopping game. In this game, there are sequentially numbered clouds that can be thunderheads or cumulus clouds. The character must jump from cloud to cloud until it reaches the start again. There is an array of clouds, c and an energy level e = 100. The character starts from c[0] and uses 1 unit of energy to make a jump of size k to cloud c[(i+k)%n]. If it lands on a thundercloud, c[i] = 1, its energy (e) decreases by 2 additional units. The game ends when the charac

View Solution →