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
)
)
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
My part 1 macro ran in 4s for 2020 rows, gonna resort to python again for part 2
Here's me for Day 15 with the Part 2 python inside an Alteryx workflow.
The Alteryx Macro takes 4s for 2020 iterations with AMP on inside the macro.
The Python for p2 takes 21s for 30m iterations.
#################################
from ayx import Package
from ayx import Alteryx
import pandas as pd
#################################
li = Alteryx.read("#1")["data"].tolist()
next = 0
dict = {n: i+1 for i, n in enumerate(li)}
target = 30000000
for i in range(len(li)+1,target):
val = next
next = i - dict.get(val,i)
dict[val] = i
df = pd.DataFrame([next],columns=["output"])
Alteryx.write(df,1)
I ended doing the second part in Python.
Thanks, @Balders, for the link to the video about this sequence https://youtu.be/etMJxB-igrc