Using OpenAI to solve AdventOfCode – Day6

Today, I took the opportunity to use OpenAI to solve a problem on the popular coding challenge website, Advent of Code (https://adventofcode.com/). Advent of Code is a series of small programming puzzles that are released daily throughout the month of December. I’m not the first to do it, some actually automated the whole process.

But I wanted to see it with my own eyes, so I decided to challenge myself by asking OpenAI to help me solve today’s puzzle without actually reading the problem myself. I simply gave OpenAI the problem prompt and let it do its thing. To my surprise, the program that OpenAI generated was able to run without any syntax errors, which is already a significant achievement IHMO.

However, when I tried to submit the solution that OpenAI generated, it turned out that the answer was incorrect. I then asked OpenAI for another solution, but it still didn’t work. At this point, I had to read the problem and provide some hints to OpenAI in order for it to generate a correct solution. I did this as I would with another human being, explaining what I thought was wrong and providing an expected result from the problem text.

After providing some additional information to OpenAI, it was able to generate a program that correctly solved the first part of the puzzle. I was impressed by OpenAI’s ability to understand the problem and generate working code, even with the information it had.

I then gave OpenAI the second part of the puzzle, and it was able to solve it almost instantly. However, I noticed that the code that OpenAI generated was somewhat repetitive, so I asked it to factorize the code and make it more elegant. To my amazement, OpenAI was able to do this, generating a program that was both correct and elegant.

In the end, I was able to solve today’s puzzle on Advent of Code using OpenAI, without having to read the problem myself or write any code. In the future, I will try to solve the puzzles on my own before using OpenAI, as I want to have fun solving the puzzles first and then have fun using OpenAI to improve upon my solutions.

I believe that technologies like OpenAI will change the way we approach programming, and I am excited to see how it will evolve in the future. It is unclear to me at this point how much it will change the role of programmers, but I am confident that it will have a significant impact on the field.


Posted

in

by

Comments

One response to “Using OpenAI to solve AdventOfCode – Day6”

  1. […] of code that is giving us a brand new puzzle every day. I’ve tried succesfuly ChatGTP to solve 2022 day6, but now I want to better understand on which it’s good or not, what problem would be harder […]

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.