Reminder: my challenge is to attempt to solve the problem without writing a single line of code. Ideally, just writing an initial prompt and get the whole code in one go. You can see the full source code (and the respective prompts) in my repository at https://github.com/nunodonato/advent-of-code-2021

Part 1

Today I decided to try and push copilot further. Instead of writing my own prompt, with step by step instructions, I basically pasted the challenge instructions directly. The only change needed was the first part where I instruct how to get the data from the input file.

Surprisingly, copilot generated the right solution without any further changes!

Part 2

Part 2 was more challenging, not sure if it’s because it relies on part 1. I tried to do the same, copying and pasting the instructions from part 2 and adding an extra instruction to get the input from the file.

The results were still quite good, but there were a couple of flaws that ended up giving the wrong result.

My struggles for today were to try and avoid these flaws, and it took me quite a number of tries to get it right.

The hardest one was to get copilot to understand that ‘down’ would ADD to the depth and ‘up’ would SUBTRACT. I’m guessing this was probably to the understanding of the model that down is usually a subtraction and up an addition. I tried rewording it, but it kept insisting with these operations.

The other flaw was that it frequently ignored the “aim” variable, even though there was a clear instruction to consider it.

After much tinkering and experimentation, I ended up deleting some lines from the original prompt and slightly changing the words on others. After some trial and error I finally got a working solution (not the 1st proposed one, though).

The final prompt became:

It seems like the submarine can take a series of commands like 'forward 1', 'down 2', or 'up 3':In addition to horizontal position and depth, you'll also need to track a third value, aim, which also starts at 0.

The commands also mean something entirely different than you first thought:
down X increases your aim by X units. 
up X decreases your aim by X units. 
forward X does two things: 
  1. It increases your horizontal position by X units. 
  2. It increases your depth by your aim multiplied by X.

Using this new interpretation of the commands, calculate the horizontal position and depth you would have after following the planned course. What do you get if you multiply your final horizontal position by your final depth?