node implimentation
This commit is contained in:
parent
845a0bcaad
commit
c7f28a5c64
18
node.py
Normal file
18
node.py
Normal 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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user