Advent of Code 2020, now in the most terse and awful python possible
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
701 B

4 years ago
#!/bin/sh
# I can't be assed to write a tokenizer so I patched GNU bc
# Source archive: https://ftp.gnu.org/gnu/bc/bc-1.07.1.tar.gz
patch_p1="
--- bc-1.07.1.orig/bc/bc.y
+++ bc-1.07.1/bc/bc.y
@@ -112,8 +112,7 @@
%nonassoc NOT
%left REL_OP
%right ASSIGN_OP
-%left '+' '-'
-%left '*' '/' '%'
+%left '+' '-' '*' '/' '%'
%right '^'
%nonassoc UNARY_MINUS
%nonassoc INCR_DECR
"
patch_p2="
--- bc-1.07.1.orig/bc/bc.y
+++ bc-1.07.1/bc/bc.y
@@ -112,8 +112,8 @@
%nonassoc NOT
%left REL_OP
%right ASSIGN_OP
-%left '+' '-'
%left '*' '/' '%'
+%left '+' '-'
%right '^'
%nonassoc UNARY_MINUS
%nonassoc INCR_DECR
"
cat d18_input.txt | ./bc-1.07.1/build/bc/bc | awk 'BEGIN {x=0} {x+=$1} END {print x}'