Project

Lines of sight

A traveler visits a region with mountains. He carries with him the list of summits and their height. He wants to know which mountains will be visible from its initial point. To help him, we will write a Python program to compute them. To make it simpler, we will assume the following hypothesis:

  • The height of the traveler is negilible.
  • The environment is discreet and normalized. The first summit is at distance 1, the second at 2... All all heights are integers.
  • He will only travel forward and there are no trees or obstacles.
  • He stands on the first summit
  • He cannot see the first summit.
  • There are not necessarily 2^m summits.
  1. In the following pictures, which summits are visibles to the observer if he stands on the first one ?
  2. Deduce the problem can essentially boils down to computing a max-prefix.
lightExample.jpg

For this project, you have to write a Python program surname.py which takes as an input a file containing the heights of the summits. As a result, your program will print, for each summit, 0 if it is not visible, 1 otherwise. Your application should produce the exact output given as example bellow

python3 surname.py data

0 1 1 0 0 0 0 1


python3 surname.py data2

0 1 0 0 0 0 0 0

The code of the project, using multiprocessing, should be sent to fabrice.huet@univ-cotedazur.fr Friday, the 27th of March.