aboutsummaryrefslogtreecommitdiff
path: root/2015/19/puzzle-2.sh
blob: cc28f1c0a96ac602a038ff210a695fd3c30b6e20 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh

# I could not figure this out on my own, but god bless this guy for doing the
# math:
# https://www.reddit.com/r/adventofcode/comments/3xflz8/day_19_solutions/cy4etju/

# Some people have inputs that could be solved by just going in reverse
# trivially, my input did not work

sed -n '
$ {
	s/^/0/
	s/\(Ar\|Rn\)//g
	s/\(Y\|$\)/-1/g
	s/[A-Z][a-z]*/+1/g
	p
}' input | bc