49 lines
917 B
Python
49 lines
917 B
Python
import sys
|
|
sys.setrecursionlimit(1000000)
|
|
|
|
print("Expert zo zoo to vie.")
|
|
raw = sys.stdin.read()
|
|
rows = raw.split("\n")
|
|
if rows[-1] == "":
|
|
rows = rows[:-1]
|
|
|
|
pos = 0
|
|
question_count = 0
|
|
answer_count = 0
|
|
def bad_database():
|
|
print("Chybna databaza")
|
|
exit()
|
|
def load():
|
|
global pos, question_count, answer_count
|
|
|
|
if pos >= len(rows):
|
|
bad_database()
|
|
|
|
text = rows[pos]
|
|
pos += 1
|
|
|
|
if text == "":
|
|
bad_database()
|
|
|
|
if "?" == text[-1]:
|
|
question_count = question_count + 1
|
|
left = load()
|
|
right = load()
|
|
return (text, left, right)
|
|
else:
|
|
answer_count += 1
|
|
return (text,)
|
|
|
|
tree = load()
|
|
|
|
if pos < len(rows):
|
|
if rows[pos] != "":
|
|
bad_database()
|
|
|
|
answers = rows[pos + 1:]
|
|
|
|
print("Pocet otazok:", question_count)
|
|
print("Pocet odpovedi:", answer_count)
|
|
print("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.")
|
|
|