Aktualizovat u8/program.py
This commit is contained in:
parent
5689284c77
commit
1fb6c19c8f
@ -5,6 +5,21 @@ class Node:
|
||||
self.no = None
|
||||
|
||||
|
||||
def create_tree(lines, index, counts):
|
||||
text = lines[index[0]]
|
||||
index[0] += 1
|
||||
node = Node(text)
|
||||
|
||||
if text.endswith("?"):
|
||||
counts[0] += 1
|
||||
node.yes = create_tree(lines, index, counts)
|
||||
node.no = create_tree(lines, index, counts)
|
||||
else:
|
||||
counts[1] += 1
|
||||
|
||||
return node
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
@ -23,7 +38,6 @@ def main():
|
||||
|
||||
counts = [0, 0]
|
||||
index = [0]
|
||||
|
||||
root = create_tree(lines, index, counts)
|
||||
|
||||
|
||||
@ -52,6 +66,5 @@ def main():
|
||||
print("Koniec")
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user