Confusing Algorithm

DJC djc at news.invalid
Mon Apr 22 17:38:29 EDT 2013


On 22/04/13 13:39, RBotha wrote:
> I'm facing the following problem:
>
> """
> In a city of towerblocks, Spiderman can
> “cover” all the towers by connecting the
> first tower with a spider-thread to the top
> of a later tower and then to a next tower
> and then to yet another tower until he
> reaches the end of the city. Threads are
> straight lines and cannot intersect towers.
> Your task is to write a program that finds
> the minimal number of threads to cover all
> the towers. The list of towers is given as a
> list of single digits indicating their height.
>
> -Example:
> List of towers: 1 5 3 7 2 5 2
> Output: 4
> """
>
> I'm not sure how a 'towerblock' could be defined. How square does a shape have to be to qualify as a towerblock? Any help on solving this problem?

It's not the algorithm that's confusing, it's the problem. First clarify 
the problem.
This appears to be a variation of the travelling-salesman problem. 
Except the position of the towers is not defined, only their height.
So either the necessary information is missing or whoever set the 
problem intended something else.




More information about the Python-list mailing list