Advent of Code with OpenRefine Day 9

My first (for now at least) failure 🙁 I’ve found this to be intractable. The problem setup is that given one end (the head) of a rope moves around, track the path taken by the other end (the tail) of the same rope – with some rules defined which determine how the tail moves in relation to the head.

The input for the problem was a list of instructions telling you how the head of the rope was being moved, you had to calculate which points the tail went through as a result.

The rules themselves are a little complicated but I think I made progress in writing some GREL that would correctly output the next location of the tail…. however, to predict the next location of the tail I needed to first calculate the location the tail was currently at. The first move is fine – we can treat the starting point as (0,0) on a 2D grid and if we know where the head of the rope has moved we can work out where the tail will end up. However, to work out where the tail ends up on the second ‘move’ we have to have already worked out where it ended up after the first move – which essentially limits us to calculating one row of data at a time – so with a list of 2000 instructions it would mean applying adding a value at a time to the ‘tail location’ column – so 2000 actions to update the column – which I could do manually or perhaps find a way of automatically generating the same instruction repeated 2000 times to fill out an operation history JSON – but it all feels really messy.

So several days later I’ve decided it’s time to move on and declare this one a loss for me (and OpenRefine) for now. Possibly others might be able to work out a better way of using OpenRefine to tackle this, and maybe I’ve missed a trick in the problem that might let me solve it – but I’ve hit my limit on this and feel it simply reflects the limitations of OpenRefine. Of course I could always write a python program inside OpenRefine to solve this – that’s always a possibility but it’s not the spirit of what I’m trying to do here 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.