1 2 3 4 5 6 7 8 9 10 11 12
import fileinput a = {} with fileinput.input() as lines: for line in lines: v, l2 = line[:-1].split(': ') a[v] = l2.split(' ') def np(v): return 1 if v == 'out' else sum(np(w) for w in a[v]) print(np('you'))
Generated with cgit - Back to sebastiano.tronto.net