The game has planets numbered . A player starts at the planet and wins the game by reaching the planet .
The planets are connected by teleports. Each teleport is described by a pair , where , and teleports a player from the planet to the planet .
You have successfully played the game through, but you want to prevent anyone else from winning the game. How many teleports do you need to remove from the game?
Implement a class Planets
with the following methods:
add_teleport
adds a teleport from the planet to the planetcalculate
returns the minimum number of teleports to remove
Implement the class in a file planets.py
according to the following template.
class Planets: def __init__(self, n): # TODO def add_teleport(self, a, b): # TODO def calculate(self): # TODO if __name__ == "__main__": p = Planets(5) print(p.calculate()) # 0 p.add_teleport(1, 2) p.add_teleport(2, 5) print(p.calculate()) # 1 p.add_teleport(1, 5) print(p.calculate()) # 2