From 1fb6c19c8fbe203db2ec5ff0e7a0e2f33c503b4f Mon Sep 17 00:00:00 2001 From: Oleksandr Mateshchuk Date: Tue, 3 Nov 2026 13:26:56 +0000 Subject: [PATCH] Aktualizovat u8/program.py --- u8/program.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/u8/program.py b/u8/program.py index 640656d..b5e019a 100644 --- a/u8/program.py +++ b/u8/program.py @@ -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()