Confusing Algorithm
Tim Roberts
timr at probo.com
Wed Apr 24 02:18:07 EDT 2013
RBotha <r at ymond.co.za> 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. ...
>
>-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?
Here's your city;
[ ]
[ ]
[ ] [ ] [ ]
[ ] [ ] [ ]
[ ][ ][ ] [ ]
[ ][ ][ ][ ][ ][ ]
[ ][ ][ ][ ][ ][ ][ ]
------------------------------
A B C D E F G
Once you see the picture, you can see that you'd thread from B to D without
involving C. I think you'll go A to B to D to F to G -- 4 threads.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list