diff --git a/day19/Makefile b/day19/Makefile index 224acfb..d0af24d 100644 --- a/day19/Makefile +++ b/day19/Makefile @@ -1,4 +1,5 @@ -INPUT := INPUT.txt +INPUT1 := INPUT-part1.txt +INPUT2 := INPUT-part2.txt SHELL := /bin/bash CFLAGS := -w -g #CFLAGS := -w -g -pg @@ -16,12 +17,13 @@ output: compile: ex1-c ex2-c ex1: - @$(TIME) ex1.bash < $(INPUT) 2>&1 - @#$(TIME) ex1-c 2020 < $(INPUT) 2>&1 + @$(TIME) ex1.bash < $(INPUT1) 2>&1 + @$(TIME) ex1-v2.bash < $(INPUT1) 2>&1 + @#$(TIME) ex1-c 2020 < $(INPUT1) 2>&1 ex2: - @$(TIME) ex2.bash < $(INPUT) 2>&1 - @#$(TIME) ex1-c 30000000 < $(INPUT) 2>&1 + @$(TIME) ex2.bash < $(INPUT2) 2>&1 + @#$(TIME) ex1-c 30000000 < $(INPUT2) 2>&1 clean: @rm -f ex1-c ex2-c core diff --git a/day19/ex1.bash b/day19/ex1.bash index cceb2fe..6dc3f3c 100755 --- a/day19/ex1.bash +++ b/day19/ex1.bash @@ -29,7 +29,11 @@ function buildtree { else if [[ ! -v MATCH[$arg] ]]; then buildtree "$((prof+1))" "$name" "${RULE[$arg]}" - MATCH[$arg]="(${!name})" + if [[ ${!name} =~ ^.$ ]] ; then + MATCH[$arg]="${!name}" + else + MATCH[$arg]="(${!name})" + fi fi res+=${MATCH[$arg]} fi