-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathd6.py
45 lines (40 loc) · 1.63 KB
/
d6.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from anytree import Node, RenderTree, Resolver
orbits = {}
with open('d6.txt') as f:
for l in f:
db = 0
orb = l.strip().split(")")
if orb[0] == 'SAN' or orb[1] == 'SAN':
#print(l)
db = 0
if orb[0] in orbits:
if orb[1] in orbits:
orbits[orb[1]].parent = orbits[orb[0]]
if db==1: print('Attached existing ', orb[1], ' to parent ', orb[0])
#orbits[orb[1]] = Node(orb[1], parent=orbits[orb[0]])
else:
orbits[orb[1]] = Node(orb[1], parent=orbits[orb[0]])
if db==1: print('Attached new ', orb[1], ' to parent ', orb[0])
else:
orbits[orb[0]] = Node(orb[0])
if db==1: print('Added new parent node ',orb[0])
if orb[1] in orbits:
orbits[orb[1]].parent = orbits[orb[0]]
if db==1: print('Attached ',orb[0],' to parent ', orb[1])
else:
orbits[orb[1]] = Node(orb[1], parent=orbits[orb[0]])
if db==1: print('Added new child node ',orb[1])
#print(orbits[orb[1]].ancestors)
#print(orbits[100].ancestors)
#a = 'X31'
a = 'YOU'
#rint(orbits[a].ancestors)
#for pre, fill, node in RenderTree(orbits[a].ancestors[0]): print("%s%s" % (pre, node.name))
#for pre, fill, node in RenderTree(orbits[a]): print("%s%s" % (pre, node.name))
#for pre, fill, node in RenderTree(orbits[8B3]): print("%s%s" % (pre, node.name))
#print(orbits)
total = 0
for o in orbits:
#print(orbits[o], ' length = ',orbits[o].depth)
total = total + orbits[o].depth
print(total)