ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2020 - BaseA Style (Day 15)

Jean-Balteryx
16 - Nebula
16 - Nebula

Discussion thread for day 15 of the Advent of Code : https://adventofcode.com/2020/day/15

10 RESPOSTAS 10
Greg_Murray
Quasar

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.

Saqueador
workflow
Greg_Murray_0-1608015117875.png


Marco

Greg_Murray_1-1608015173719.png

 

jdunkerley79
ACE Emeritus
ACE Emeritus

Part 1 in BaseA, part 2 resorted to Abacus functions (VarNum)

 

Saqueador
jdunkerley79_0-1608034136826.png

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
   )
)​

 

Steph_Maddrell
Asteroide

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:

Saqueador
stephM_1-1608036851792.png

Macro:

Saqueador
stephM_0-1608036802718.png
dsmdavid
Bólide

On hindsight, this was not the right day to play golf...

Saqueador
Part I, the browse is needed to be able to scroll down all the rows
dsmdavid_0-1608040457380.png

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.

 

AkimasaKajitani
17 - Castor
17 - Castor

Day15!

 

My Part 1 Macro takes 4 minutes 30 seconds, but I enabled AMP Engine it is 10.2 seconds.

 

 

Saqueador
AkimasaKajitani_0-1608041766780.png

Macro:
AkimasaKajitani_2-1608042063865.png

 

 

After that I made non Macro version at Part 1.

 

This takes 0.7sec(no AMP). When enabled AMP, 0.5sec.

 

Saqueador
AkimasaKajitani_1-1608041847041.png

 

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).

 

 

danilang
19 - Altair
19 - Altair

Part 1 with no macro runs in 0.6 seconds.  It generates really long strings though so it bogs down when trying part 2

 

Saqueador
danilang_0-1608055463295.png

 

Dan

Balders
Bólide

My part 1 macro ran in 4s for 2020 rows, gonna resort to python again for part 2

Balders
Bólide

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.

 

Saqueador
In the Macro I use negative record IDs because they helped with summarise sorts but then I managed to get rid of summarise tools and filtered out old rows more efficiently with the sample tools. However I've left the negative record IDs in because why not. That's why you see record ID - 1 in the calcs. 

Main Workflow

AoC 15 1.png
Macro
AoC 15 2.png
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)
dsmdavid
Bólide

I ended doing the second part in Python.
Thanks, @Balders, for the link to the video about this sequence https://youtu.be/etMJxB-igrc

 

Rótulos
Autores com maior número de soluções