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 REPLIES 10
cgoodman
ACE Emeritus
ACE Emeritus

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.

 

Spoiler
cgoodman3_0-1610531738122.png


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] ELSEIF
findstring(substring([Row-1:Data],0,([Row-1:RowCount]-1)*5),substring([Row-1:Data],5*([Row-1:RowCount]-1),5))=-1
THEN
[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

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
Labels
Top Solution Authors