#!/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}'