Advent of Code 2020 - BaseA Style (Day 15)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Discussion thread for day 15 of the Advent of Code : https://adventofcode.com/2020/day/15
- Labels:
- Advent of Code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
)
)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Day15!
My Part 1 Macro takes 4 minutes 30 seconds, but I enabled AMP Engine it is 10.2 seconds.
Macro:
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
My part 1 macro ran in 4s for 2020 rows, gonna resort to python again for part 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
Main Workflow
Macro
Python
#################################
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I ended doing the second part in Python.
Thanks, @Balders, for the link to the video about this sequence https://youtu.be/etMJxB-igrc
