Advent of Code F# — Day 12

ps. look out for all my oth­er solu­tions for Advent of Code chal­lenges here.


Day 12

See details of the chal­lenge here.

The input for today’s chal­lenge looks like this:

cpy 1 a
cpy 1 b
cpy 26 d
jnz c 2
jnz 1 5
cpy 7 c

This is very sim­i­lar to Day 23 of Advent of Code 2015 and look­ing at my solu­tion then I thought I could sim­pli­fy it slight­ly this time around.


Part 2

As you head down the fire escape to the mono­rail, you notice it didn’t start;
reg­is­ter c needs to be ini­tial­ized to the posi­tion of the igni­tion key.

If you instead ini­tial­ize reg­is­ter c to be 1, what val­ue is now left in reg­is­ter a?

because of the work we did in part 1, part 2 is a sim­ple one lin­er:

let part2 = (exe­cute [ “c”, 1 ] inputs).[“a”]