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()