Task 2: Lightposts
Task 2: Lightposts
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.
H1 | H2 | H3 | H4 | H5 |
L | D | L | L | L |
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.
Similar topics
» Task 4: MasterCoder
» Task 6: The cake is a lie!
» Task 1: Rectangle Area
» Task 3: Cave Troll
» Task 5: As easy as bagels
» Task 6: The cake is a lie!
» Task 1: Rectangle Area
» Task 3: Cave Troll
» Task 5: As easy as bagels
Permissions in this forum:
You cannot reply to topics in this forum