node implimentation

This commit is contained in:
randomuser 2022-07-09 18:45:25 -05:00
parent 845a0bcaad
commit c7f28a5c64

18
node.py Normal file
View File

@ -0,0 +1,18 @@
# node implementation
class Node:
def __init__(self):
self.children = []
self.score = None
def calculate(self):
if self.children == []:
return self.score
total = 0
items = 0
for i in self.children:
score = i.calculate()
if score != None:
items += 1
total += score