Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def travel(light_years):
- global starting_fuel, abort_missing
- if starting_fuel >= light_years:
- starting_fuel -= light_years
- print(f"The spaceship travelled {light_years} light-years.")
- else:
- print("Mission failed.")
- abort_missing = True
- def enemy(total_enemy_armor):
- global starting_ammunition, starting_fuel, abort_missing
- if starting_ammunition >= total_enemy_armor:
- starting_ammunition -= total_enemy_armor
- print(f"An enemy with {total_enemy_armor} armour is defeated.")
- elif starting_fuel >= total_enemy_armor * 2:
- starting_fuel -= total_enemy_armor * 2
- print(f"An enemy with {total_enemy_armor} armour is outmaneuvered.")
- else:
- print("Mission failed.")
- abort_missing = True
- def repair(number):
- global starting_ammunition, starting_fuel
- starting_fuel += number
- starting_ammunition += (number * 2)
- print(f"Ammunitions added: {number * 2}.")
- print(f"Fuel added: {number}.")
- def titan():
- print("You have reached Titan, all passengers are safe.")
- route = input().split("||")
- starting_fuel = int(input())
- starting_ammunition = int(input())
- abort_missing = False
- for command in route:
- if "Titan" not in command:
- command, data = [int(x) if x.isdigit() else x for x in command.split()]
- else:
- titan()
- break
- if "Travel" in command:
- travel(data)
- elif "Enemy" in command:
- enemy(data)
- elif "Repair" in command:
- repair(data)
- if abort_missing:
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement