Tag: OpenAI

  • Using OpenAI ChatGTP to solve advent of code 2022 – Day 1

    I’m recording my interactions with OpenAI ChatGTP to solve advent of code, here is some context.

    Part 1

    I ask it to solve a problem, but hit the enter key too early, without giving the problem.
    It gave an answer anyway. Obviously it didn’t solve our problem. We can notice that the program works, and actually solve the problem “sum the numbers in a file, each number in one row”.

    Adding the real problem

    So I put the real problem (screenshot is cut, real puzzle is here):

    And the answer:

    Funny thing, it give context and explain a bit what the program is doing.
    But, unfortunately, the program doesn’t give a valid solution. After reviewing the code, I see that it’s considering the first value of each group as the name of the group, but there is no name only values. Let’s give it this information…

    Here we see one of the ChatGTP’ strength , the ability to remember the conversation.
    After a quick review, I noticed that it understood that it had to change elf, the program is almost doing it but the issue is that the part where it want to change elf, it take always the same name “Elf”.
    We’re close…

    This time, the program gives the correct answer!

    Part 2

    Let’s try the direct approach

    Well, it worked directly, nothing to add!

  • 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.