Task 2: Lightposts

Go down

Task 2: Lightposts

Post  Admin on Sat Jun 04, 2011 9:13 am

There is a street across the road that has houses evenly distributed along its path. There are also lamplights outside of each house. At night, the lamplights turn on and light up the houses. However, due to a recent storm, some lamplights were broken. Unlighted houses are too dark and spooky for the elderly residents that live in the street. They've enlisted you to help them to find the longest lighted path in their street. A lighted path is a continuous segment of the street where every house that is in the segment is lighted. For example:


H1,H2... are all houses on the road. L means its lighted and D means its not. In this case, H1 is a lighted path, so is H3-H5. But H1-H3 is not a lighted path because H2 is unlighted.

Given the number of houses are the street and foreach house, whether it is lighted or not, make a program that calculates the LONGEST lighted path in the street.


Posts : 21
Join date : 2011-06-04

View user profile http://nsbcoder.board-directory.net

Back to top Go down

Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum