1 divert(-1)dnl -*- m4 -*-
2 # Usage: m4 [-Dfile=day16.input] day16.m4
4 include(`common.m4')ifelse(common(16), `ok', `',
5 `errprint(`Missing common initialization
8 define(`Sue', `check{')
9 define(`input', translit((include(defn(`file'))), nl`:', `},'))
10 define(`children', ==3)define(`cats', >7)define(`samoyeds', ==2)
11 define(`pomeranians', <3)define(`akitas', ==0)define(`vizslas', ==0)
12 define(`goldfish', <5)define(`trees', >3)define(`cars', ==2)
13 define(`perfumes', ==1)
14 define(`check', `ifelse(c1($2, $3)c1($4, $5)c1($6, $7), 111, `define(`part1',
15 $1)', c2($2, $3)c2($4, $5)c2($6, $7), 111, `define(`part2', $1)')')
16 define(`c1', `ifelse(translit($1, `<>='), $2, 1)')
17 define(`c2', `eval($2 $1)')
18 translit(defn(`input'), `{}', `()')