Question: ( 1 ) Write a program that inputs a topographical map and outputs the locations that are in the shade, given a certain predetermined position

(1) Write a program that inputs a "topographical" map and outputs the locations that are in the shade, given a certain predetermined position of the sun.
The input is an nn matrix representing n2 evenly spaced points on a square piece of land. The values in the matrix are integers ranging from 0 to 100. Each value represents the "altitude" of the land at the corresponding point.
The output is an nn matrix of 0s and 1s, where the output value is 0 if the land at that point is in the sunlight and 1 if the land at the point is in the shade.
Let us assume that the sun is shining from the west (W). A location is in the shade if there is a hill to its west high enough to block the sun. To compute which locations are in the shade: First, the locations in the leftmost column are by definition in the sunlight. For each remaining location (i, j), it is in the shade if there is another location (i,j-k) whose altitude is at least 4k greater than the altitude at (i, j). This is an "exhaustive" search for different locations with different i,j and k.
 (1) Write a program that inputs a "topographical" map and outputs

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!