#!/usr/local/bin/python

import pathlib
import random
import string

with open("/flag") as f:
    random.seed(f.read())

init_path = pathlib.Path(__file__)
planets_path = (pathlib.Path(__file__).parent / "planets.txt")
launch_path = (pathlib.Path(__file__).parent / "launch")
launch_template_path = (pathlib.Path(__file__).parent / "launch.template")

planet = random.choice(planets_path.read_text().strip().splitlines())

template = string.Template(launch_template_path.read_text())
launch_path.write_text(template.safe_substitute(planet=planet))

launch_template_path.unlink()
planets_path.unlink()
init_path.unlink()
