There was an error while loading. Please reload this page.
1 parent cbcc2ea commit 3478705Copy full SHA for 3478705
2025/day11/p2-golf-actual.sh
@@ -1,6 +1,7 @@
1
# requries bash 5.3+
2
-declare -A c;i=$1
3
-f(){ local h=$1$2$3 fft=$2 dac=$3;[ $1 = out ]&&
4
-c[$h]=$[$2&$3]||[ -z ${c[$h]} ]&&{ eval "(($1++))"
+# ./p2-golf-actual.sh [input]
+declare -A c;i=$1;f(){
+local h=$1$2 z=$2;[ $1 = out ]&&c[$h]=$[$2==2]||
5
+[ -z ${c[$h]} ]&&{ [[ $1 =~ fft|ac ]]&&((z++))
6
for x in `grep ^$1 $i|tail -c+6`;do((c[$h]+=${
-f $x $fft $dac;}))done };echo $[c[$h]];};f svr
7
+f $x $z;}))done };echo $[c[$h]];};f svr
0 commit comments