#!/usr/bin/env python3 filename = "in/day21.ref" # filename = "in/day21.pzl" [exec(f"def {line.strip().split(':')[0]}(): return {int(line.strip().split(':')[1].strip())}", globals()) if (line != 'asdf' and line.strip().split(':')[1].strip().isnumeric()) else exec(f"def {line.strip().split(':')[0]}(): return {line.strip().split(':')[1].strip().split(' ')[0]}() {line.strip().split(':')[1].strip().split(' ')[1]} {line.strip().split(':')[1].strip().split(' ')[2]}()", globals()) if line != 'asdf' else exec('print(root())', globals()) for line in open(filename).readlines() + ['asdf']]