From a41457c2c1c1099058f47bec7f2b0a89e5a7515f Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 24 Jan 2024 21:12:24 -0600 Subject: [PATCH] day 9 golf to 349 effective bytes The first newline remains mandatory for 349/353. Several improvements here: - ending the recursion more robustly shaves some bytes - use less quoting in translit - spell shift() twice in order to simplify how $2 is represented and use _(^) fewer times - elide some _(=) where a later eval still works and where the size of the input doesn't explode. (If I didn't care about the solution completing within seconds, I could elide a few more _(=), but the size of the input explodes). --- 2023/day09.golfm4 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/2023/day09.golfm4 b/2023/day09.golfm4 index 80794d7..9f4eead 100644 --- a/2023/day09.golfm4 +++ b/2023/day09.golfm4 @@ -1,5 +1,5 @@ -define(_,`ifelse($1,%,`translit($2,`$3',`,')',index(`$1',^),0,`shift($@)',$1,$,`' -,$1,=,`eval($2)',$1,~,`_(=,$5+$3),_(=,$2- $4)',$1$2,+,,$1,+,`_(,_(%,$2,` ')),_( -+,_(^_(^$@)))',$1$2,>,`) _(=,',$1,>,`+$2_(>,_(^_(^_(^$@))))+$3',$1$2$3$4,00, -`0,0',$1,,`_($2,(^,_(=,$3- $2)),_(^_(^$@)))',$4,,`_(~,$1,_(,_$2),$3)', -`_($1,(^,_$2,_(=,$4- $3)),_(^_(^_(^$@))))')')_(=,_(>,_(+,_(%,include(I),_($))))) +define(_,`ifelse(index($1,^),0,`shift(shift($@))',$1,%,`translit($2,$3 +,(,))',$1,=,`eval($2)',$1,~,`($5+$3),($2-$4)',`$1$2',+,,$1,+,`_(,_(%, +$2,* )),_(+,_(^$@))',`$1$2',>,`) _(=,',$1,>,`+$2_(>,_(^,_(^$@)))+$3', +$1$4,,`$2,$3',$1,,`_($2,_(=,$3- $2),_(^$@))',$4,,`_(~,$1,_(,$2),$3)', +`_($1,`$2,_(=,$4- $3)',_(^,_(^$@)))')')_(=,_(>,_(+,_(%,include(I),*)))) -- 2.11.4.GIT