Last active
September 11, 2023 07:35
-
-
Save albertas/b017abcc5a04bc9ad8d17a3e2fd93a6e to your computer and use it in GitHub Desktop.
CCT academy task 2023
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
There are street lights placed evenly every 20 meters on a straight road. | |
Most of the street lights are working and have the same illumination intencity. | |
Non-working street lights are provided as a list of their indexes. | |
If a street light is not working - its position can still be illuminated by neighboring lights. | |
Illumination is decreasing exponentially when the distance increases from a street light. | |
Please find an index of a street light, which has the lowest illumination. Its light bulb will be replaced. | |
Notes: | |
- The road lenght can be from 0 to 2000000m. | |
- The street lights are indexed from 0 and the first one stands at the begining of the road. | |
- The intensity of illumination can be calculated using f(x) = 3^(-(x/90)^2) formula, | |
where x is a distance from the street ligth in meters. | |
- If the street light is very far away and its illumination intencity is less than 0.01 - its illumination has to be ignored. | |
- In case there are several street lights with the same lowest illumination - provide the one with the lowest index. | |
Example: | |
road_length = 200 | |
non_working_street_lights = [4, 5, 6] | |
The length of the road is 200 meters and it has 11 street lights on it. Lights with indexes 4, 5 and 6 are not working. | |
The bulb of the street light with index 5 has to be replaced, because the illumination at it is the lowest. | |
Optional (for extra Karma points): | |
- Please find the minimal number of light bulbs, which is needed to be replaced | |
to make cumulative illumination intencity at every street light non less than 1. | |
""" | |
def find_index_of_darkest_street_light(road_length: int, not_working_street_lights: list[int]) -> int: | |
# TODO: Replace this with a real implementation: | |
return 5 | |
if __name__ == "__main__": | |
# This is an example test. When evaluating the task, more will be added: | |
assert find_index_of_darkest_street_light(road_length=200, not_working_street_lights=[4, 5, 6]) == 5 | |
print("ALL TESTS PASSED") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment