aboutsummaryrefslogtreecommitdiff
path: root/2015/19/puzzle-2.sh
diff options
context:
space:
mode:
authorThomas Voss <thomasvoss@live.com> 2021-12-01 19:15:48 +0100
committerThomas Voss <thomasvoss@live.com> 2021-12-01 19:15:48 +0100
commit9a4ea19ae955c86312c62098830a0f0e2994196d (patch)
tree4735be125fc4e1038c310dc724efcafa2339453a /2015/19/puzzle-2.sh
parent394df58d6da6928a6a3ebae31362342deca74b48 (diff)
Add day 19 solutions
Diffstat (limited to '2015/19/puzzle-2.sh')
-rwxr-xr-x2015/19/puzzle-2.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/2015/19/puzzle-2.sh b/2015/19/puzzle-2.sh
new file mode 100755
index 0000000..78c3ce5
--- /dev/null
+++ b/2015/19/puzzle-2.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env 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 has 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