r/adventofcode • • 3h ago

Meme/Funny AoC in Prolog?!?!

I was filling in the unoficcial AoC survey

(⭐ Take the (~5min) Unofficial AoC 2026 Survey: https://forms.gle/JbZKoBqzG248Z6RV6 ⭐)

And I saw this:

Who the hell is out there doing AoC in Prolog😭

9 Upvotes

6 comments sorted by

8

u/jeroenheijmans 2h ago

Check out https://jeroenheijmans.github.io/advent-of-code-surveys/ and click "Toggle data table...." in the first section, it has these numbers for Prolog:

2018 -  5 (0.5%)
2019 -  3 (0.2%)
2020 -  6 (0.3%)
2021 - 11 (0.3%)
2022 -  9 (0.2%)
2023 -  9 (0.3%)
2024 - 11 (0.3%)
2025 -  5 (0.2%)
2026 - ?? (???%)

So quite a handful, more typically than Racket, Smalltalk, Brainf*ck, COBOL, Erlang, Powershell, and several others!

Personally I was taught Prolog in uni around 2002 and absolutely loved the programming language. I mean, come on: a language that quite often replies with just "No!" - what's not to love!? :D

5

u/gredr 2h ago

Prolog is neat, and learning it will make you a better programmer.

3

u/flwyd 57m ago

I've definitely considered doing a whole AoC season in Prolog, but it hasn't yet come to the top of my priority queue.

Advent of Code is a good opportunity to take a whole new programming paradigm and figure out how you can use it to solve a problem that you know how to solve in a more familiar paradigm. So give Prolog a try!

2

u/thondat 1h ago

not using it this year, but i've done some AoC challenges in Prolog before to learn the language. it is alien compared to ALGOL-likes, and considerably different from Lisps and MLs as well. but it can be useful once you get the hang of unification and backtracking. SWI-Prolog (and AFAIK Scryer too now) has e.g. clpfd (Constraint Logic Programming over Finite Domains) which extends the language to make it convenient for satisfying integer constraints: something for which you would use PuLP or z3 or some other solver library in another language. there's also Definite Clause Grammars where you write a grammar in what looks quite similar to EBNF but is actually Prolog code. this is useful for parsing structured input, but can also be used for threading state. all in all, i'm still fascinated and will probably revisit Prolog some time.

1

u/Immediate_Form7831 12m ago

I have done a few puzzles in Prolog. Not many, but some puzzles lend themselves very well to solving in Prolog.