Untitled

mail@pastecode.io avatar
unknown
plain_text
18 days ago
589 B
4
Indexable
Never
def howFarCanYouGo(mainTank: int, secondaryTank: int) -> int:
    distance = 0
    
    while mainTank > 0:
        fuel_to_use = min(mainTank, 5)
        distance += fuel_to_use * 10
        mainTank -= fuel_to_use

        if fuel_to_use == 5 and secondaryTank > 0:
            mainTank += 1
            secondaryTank -= 1
    
    return distance

if __name__ == "__main__":
    mainTank = 10  # example main tank fuel
    secondaryTank = 5  # example secondary tank fuel
    distance = howFarCanYouGo(mainTank, secondaryTank)
    print(f"The vehicle can travel {distance} kilometers.")
Leave a Comment