Hey folks, over the weekend I finally got started on a project I'd wanted to try this year: solving advent of code challenges within OpenRefine. I know we're already pretty late in the challenges but I wanted to see if anyone else is interested in giving this a try.
I've only made it past day 1 part 1, but to get there I added a reduce GREL function to transform arrays. I'm still working on part 2, but in the meantime here is my solution for part 1:
solution for advent of code day 1, part 1
- Import the data as a project with a single column
- Transform the input such that R numbers are positive and L numbers are negative
- Create a new column with where the dial ends up after the rotation in the current row
- Use a text facet to see how many zeros are in the project
reduce(
forRange(
0,
row.index + 1,
1,
v,
with(
cross(v),
prev,
prev[0].cells["Column 1"].value
)
),
v,
acc,
50,
with((acc + v) % 100, normalized,
if(
normalized > 99,
abs(100 - normalized),
if(
normalized < 0,
100 + normalized,
normalized
)
)
))