Sundial | Onsite | The Wire
Anonymous User
624

There is a square field which is full of trees planted in a grid. Each tree takes up one position and has a height between 0and 10.
You are tasked with hanging an electric wire that runs straight over the field. The wire may enter the field from the north (vertically) or west (horizontally) direction. The wire can only pass above trees that are of a lesser height. The wire hangs at the same height for its entire length over the field.
Write a program that takes as input the height of each tree in the field. It should return the direction (N or W) and the index from which the wire should enter the field, so that it is hanging closest to the ground.

Comments (3)