Guest User

Untitled

a guest
Dec 10th, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. from Tree import *
  2. import operator
  3.  
  4. def get_input(file):
  5.     f = open(file, "r")
  6.     result = list(map(lambda x: x[0:-1], f.readlines()))
  7.     f.close()
  8.     return result
  9.  
  10.  
  11. def solve6a():
  12.     input = get_input("input")
  13.     t = Tree()
  14.  
  15.     for line in input:
  16.         t.add_node(line)
  17.  
  18.     t.compute_orbits_per_node()
  19.     total_orbits = 0
  20.     for n in t.nodes:
  21.         total_orbits += n.orbits
  22.     print("6a: Total orbits: {}".format(total_orbits))
  23.     t.nodes.sort(key=operator.attrgetter('orbits'))
  24.     print(t.nodes)
  25.  
  26. solve6a()
Advertisement
Add Comment
Please, Sign In to add comment