Created
February 12, 2020 00:45
-
-
Save HauptJ/ee93757c7abaf1802dc15c80233b77f7 to your computer and use it in GitHub Desktop.
Drone Flight Planner - https://www.pramp.com/challenge/BrLMj8M2dVUoY95A9x3X
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
def calc_drone_min_energy(route): | |
if not route: | |
return 0 | |
initialz = route[0][2] | |
greatestz = initialz | |
for z in range(1, len(route), 1): | |
if route[z][2] > greatestz: | |
greatestz = route[z][2] | |
print(greatestz) | |
print(route[z][2]) | |
energy = abs(greatestz - initialz) | |
return energy | |
#route = [[0, 2, 10],[3, 5, 0],[9, 20, 6],[10, 12, 15],[10, 10, 8]] | |
#print(calc_drone_min_energy(route)) | |
""" | |
[[0,2,6] | |
[10,10,20]] | |
input: route = [ [0, 2, 10], | |
[3, 5, 0], | |
[9, 20, 6], | |
[10, 12, 15], | |
[10, 10, 8] ] | |
output: 5 # less than 5 kWh and the drone would crash before the finish | |
# line. More than `5` kWh and it’d end up with excess energy | |
starting pt 0 energy | |
z access only care about up and down | |
10 0 | |
0 +10 | |
6 -6 | |
15 -9 | |
8 +7 | |
___ | |
15 | |
greatestZ = initialz | |
for each z+1 in zaxis: | |
if z > greatestz | |
greatestz = z | |
energy = greatestz - initialz | |
10 0 6 15 8 | |
energy = 15 - 10 = 5 | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment