Discussion thread for day 15 of the Advent of Code : https://adventofcode.com/2020/day/15
I only completed part 1. Interested to see if there are baseA solutions for part 2. My macro is pretty slow (~3.5 minute for the input). I am sure I overcomplicated it.
Marco
Part 1 in BaseA, part 2 resorted to Abacus functions (VarNum)
iif([RowCount]<=[Init], GetWord([Field1], [RowCount]-1) + iif([RowCount]>1 AND VarNum([Row-1:Value], RowCount - 1),"",""), ToString( iif(VarNumExists([Row-1:Value]), RowCount-VarNum([Row-1:Value])-1, 0) + VarNum([Row-1:Value], RowCount - 1) * 0 ) )​
My part 1 solution based on iterative macro. Runs in 3.5 mins so I can't see that I'll be solving part 2 any time soon!
Workflow:
Macro:
On hindsight, this was not the right day to play golf...
Part II... the logic would hold, but it's not really efficient. I've switched to an iterative macro that runs ~ 300 iterations per second, so maybe I'll have some results in one day...😅 EDIT: running 100k took almost 20 min, so the timeframe for solutions has moved to 1 week... I think I'm giving up on BaseA for this one.I do not give up that there must be a pattern to be found. I've just not seen it yet.
Day15!
My Part 1 Macro takes 4 minutes 30 seconds, but I enabled AMP Engine it is 10.2 seconds.
After that I made non Macro version at Part 1.
This takes 0.7sec(no AMP). When enabled AMP, 0.5sec.
But at Part 2, when I enabled AMP Engine, Multi-Row Formula tool throw the error "String variable switched type".
So I have tried another macro, but it takes longer(Now Running).
Part 1 with no macro runs in 0.6 seconds. It generates really long strings though so it bogs down when trying part 2
Dan
I ended doing the second part in Python.Thanks, @Balders, for the link to the video about this sequence https://youtu.be/etMJxB-igrc
Realised I had never posted my solution to Day 15. This one took me a lot of debugging as I went for the option of generating a longer string with generate rows and multi-row formulas to go through the 2020 Elf answers and avoid an iterative macro. The result is a run time of 1.2 seconds, however it's not fast enough for the part 2.
The formula for the multi row is, does a string walk with all numbers padded to strings of a fixed length of 4 and split by a pipe delimiter:IF ISNull([Row-1:Data]) THEN [Data] ELSEIFfindstring(substring([Row-1:Data],0,([Row-1:RowCount]-1)*5),substring([Row-1:Data],5*([Row-1:RowCount]-1),5))=-1THEN[Row-1:Data]+"|0000"ELSE[Row-1:Data]+"|"+padleft(tostring(([RowCount]-1)-((length(right(reversestring([Row-1:Data]),Length([Row-1:Data])-5))-(findstring((right(reversestring([Row-1:Data]),Length([Row-1:Data])-5)),left(reversestring([Row-1:Data]),5))))/5)),4,"0")ENDIF