2016-12-18 Advent of Code in Javascript

Today I’m going for Javascript. Advent of Code, day 9, here I come. I’m going to run the code on the command line using node.

Advent of Code

node

Part 1: Process a string containing instructions such as (AxB) where A and B are integers saying to repeat the next A characters B times. What’s the length of the expanded string? The expansions are not processed. Examples given:

Part 2: Same thing, but now expansions *are* processed.

Part 1 was more or less simple, but as you can see I needed a lot of console output to get my off-by-one errors under control and it also took me quite some time to find the `6 + "1" → 61` error.

When I saw the input provided I decided not to worry about the “ignore whitespace” section of the puzzle.

Part 2 surprised me because the recursive expansions make my previous approach untenable. I waited for a minute or two and aborted it. So now I can’t just build representations of the intermediate strings.

​#Javascript ​#Advent of Code ​#Programming