News for hackers. Stuff that matters.
Re:Placing #1 in Advent of Code with GPT-3 by surfsvammel on Sunday December 04, 2022 @02:32AM (#33851451)
I saw this yesterday. It’s very impressive, and a bit scary.

I myself set my alarm early every morning (problems are dropped at 06:00) in my TimeZone.

It would be nice to only compete with other humans, but, I do understand that it would be impossible to enforce without totally changing AoC.

I hope that we won’t see the competitive element of AoC disappear over the next couple of years as AI models get better and better at getting on the leaderboard.

I’m not bitter, and I don’t want to stand in innovations way. I’m just a bit nostalgic and want AoC to stay the same:)

Re:Placing #1 in Advent of Code with GPT-3 by jodrellblank on Sunday December 04, 2022 @03:36AM (#33851789)
Earlier I was wondering what AoC would be like if it got rid of the time and instead the challenge was that you only get one chance to submit and get the right answer; what would people do differently in choice of language, test suites, fuzzing, reading, etc.

But it seems GPT aced that as well.

Re:Placing #1 in Advent of Code with GPT-3 by jchmrt on Sunday December 04, 2022 @05:17AM (#33852281)
Why do you think GPT aced that? As far as I can tell from the code it sends in up to 10 guesses.
Re:Placing #1 in Advent of Code with GPT-3 by surfsvammel on Sunday December 04, 2022 @07:27AM (#33853065)
If you submit a wrong answer, you cannot submit again in 60 seconds. I think that back-off time increases with every wrong submission.

The AI has a finish time of 10s, meaning that it only submitted once (unless it is using multiple accounts to get around the back-off)

Re:Placing #1 in Advent of Code with GPT-3 by colonwqbang on Sunday December 04, 2022 @03:58AM (#33851887)
I'm expecting that the model will struggle once the problems start to get harder. The first few days of AOC are very trivial. To keep AoC competitive we would just need to start at a slightly higher difficulty.
Re:Placing #1 in Advent of Code with GPT-3 by sixstringtheory on Sunday December 04, 2022 @04:36AM (#33852052)
Which would raise the bar for newcomers and turn it into a GPT competition instead of a coding one.
Re:Placing #1 in Advent of Code with GPT-3 by Gigachad on Sunday December 04, 2022 @06:32AM (#33852667)
Feels like AI is raising the bar on everything. Sure, you can draw better than AI, but it takes years of painstaking practice outputting work worse than a beginner with a prompt.
Re:Placing #1 in Advent of Code with GPT-3 by misja111 on Sunday December 04, 2022 @07:33AM (#33853102)
Give AI a couple more years and it will draw better than you anyway.
Re:Placing #1 in Advent of Code with GPT-3 by visarga on Sunday December 04, 2022 @08:22AM (#33853478)
But it will be still you that initially has to intent to create something and manage the process. You got to manage AIs in order to do things. I bet in the future all corporate employees will be given access to a team of bots to manage their work.
Re:Placing #1 in Advent of Code with GPT-3 by Gigachad on Sunday December 04, 2022 @05:27PM (#33858645)
So basically the dull drone work remains but the actually rewarding things are being automated.
Re:Placing #1 in Advent of Code with GPT-3 by misja111 on Sunday December 04, 2022 @07:32AM (#33853096)
I'm not so sure of that. I asked GPT to code an algorithm to find the shortest path in a graph and it had no trouble coding it using BFS.
Re:Placing #1 in Advent of Code with GPT-3 by yunwal on Sunday December 04, 2022 @10:12AM (#33854368)
That also seems trivial. The model was likely trained on thousands of BFS implementations. Non-trivial is when the algorithm required to solve the problem is rare, or when the translation from word problem to algorithm is significant/requires other knowledge.
Re:Placing #1 in Advent of Code with GPT-3 by misja111 on Sunday December 04, 2022 @12:09PM (#33855432)
I didn't ask it to use BFS, I asked it to write a program that would come up with the shortest path in a graph. It decided to use BFS on its own. I agree that BFS is very well known for coding shortest path problems. However op's comment was about AoC problems in the harder stages, and those typically don't go any deeper than BFS or A* search.
Re:Placing #1 in Advent of Code with GPT-3 by cercatrova on Sunday December 04, 2022 @02:33PM (#33856888)
Can you ask it for something more complicated like the traveling salesman implementation (which is NP hard yes but more efficient algorithms exist)?

It gave me a genetic algorithm:

// Define a class for representing a single city in the TSP class City { constructor(public x: number, public y: number) {}

  // Calculate the distance to another city
  public distanceTo(city: City): number {
    const dx = this.x - city.x;
    const dy = this.y - city.y;
    return Math.sqrt(dx * dx + dy * dy);
  }
}

// Define a class for representing a solution to the TSP class Tour { private cities: City[]; private fitness = 0; private distance = 0;

  constructor(tour?: City[]) {
    if (tour) {
      this.cities = tour;
    } else {
      this.cities = [];
    }
  }

  // Add a city to the tour
  public addCity(city: City) {
    this.cities.push(city);
  }

  // Get the tour as an array of cities
  public getTour(): City[] {
    return this.cities;
  }

  // Get the fitness of the tour (lower is better)
  public getFitness(): number {
    if (this.fitness === 0) {
      this.fitness = 1 / this.getDistance();
    }
    return this.fitness;
  }

  // Get the total distance of the tour
  public getDistance(): number {
    if (this.distance === 0) {
      let tourDistance = 0;

      // Loop through all cities in the tour and sum the distances
      for (let i = 0; i < this.cities.length; i++) {
        const fromCity = this.cities[i];
        const toCity = this.cities[0];
        if (i + 1 < this.cities.length) {
          toCity = this.cities[i + 1];
        }
        tourDistance += fromCity.distanceTo(toCity);
      }

      this.distance = tourDistance;
    }
    return this.distance;
  }

  // Generate a random tour
  public generateIndividual(): Tour {
    const newTour = new Tour();
    for (let i = 0; i < Tour.numberOfCities(); i++) {
      newTour.addCity(Tour.getCity(i));
    }
    return newTour.shuffle();
  }

  // Shuffle the cities in the tour
  public shuffle(): Tour {
    const newTour = new Tour(this.cities);
    const currentIndex = newTour.cities.length;
    let temporaryValue;
    let randomIndex;

    // While there remain elements to shuffle...
    while (currentIndex !== 0) {
      // Pick a remaining element...
      randomIndex = Math.floor(Math.random() * currentIndex);
      currentIndex -= 1;

      // And swap it with the current element
      temporaryValue = newTour.cities[currentIndex];
      newTour.cities[currentIndex] = newTour.cities[randomIndex];
      newTour.cities[randomIndex] = temporaryValue;
    }

    return
   ...
It stopped here and continued when I asked it to but I stopped here because I don't want to exceed the HN limit.
Re:Placing #1 in Advent of Code with GPT-3 by candlemas on Sunday December 04, 2022 @09:09AM (#33853828)
You could see how it does on the later stages of previous years.