Advent of Code 2015 Day 13 Solution - BASLOAD

Post Reply
MarkTheStrange
Posts: 21
Joined: Sat Nov 26, 2022 6:24 pm

Advent of Code 2015 Day 13 Solution - BASLOAD

Post by MarkTheStrange »

Screenshot 2025-01-24 at 22.06.39.png
Screenshot 2025-01-24 at 22.06.39.png (340.78 KiB) Viewed 99 times
This is a pretty boring text-only program, but I'm posting it here so I can include a try-it-now link in the GitHub README.

After completing Advent of Code 2024, I decided to go back and do the earlier years, starting with the first one in 2015. I'm using a script to pick a different random programming language to use for each day's puzzle, and for day 13 it picked BASIC. I decided to use X16 BASIC by way of BASLOAD, so here we are.

You can read the problem description; it's an optimization problem, figuring out the best order in which to seat guests around a circular table given some information about how much they want or don't want to sit next to each of the other guests. My solution isn't particularly clever; it just tries all the possibilities. The fact that the table is circular means all rotations of a given arrangement are equivalent, so there's 1/N as many permutations as there would be otherwise, but it's still not fast on the X16; the full 8-guest problem (which adds a 9th guest in part 2) takes almost an hour to run.

The program defaults to running on a small sample from the problem description, which finishes in a few seconds. Per AoC guidelines I haven't included my actual input file, but I did include a randomly-generated one of the same size as my input called FULL.TXT if you want to try it.

Try It Now!
Attachments
aoc2015day13.zip
(3.33 KiB) Downloaded 9 times
Post Reply