fub: A photo of an ADM3A terminal (ADM3A)
[personal profile] fub

So I said I was probably not going to do the other days of Advent of Code, but it’s just too much fun, and I’m re-learning some fun Prolog tricks. And some of the assignments are of the type “find (or count) all occurrences where X is true”, and Prolog is ideally suited for that! I solved the assignment for day 2 in basically ten lines of code: nine for a scoring table and one line to do the actual work!


The assignment for day 3 required string manipulation, which is not something Prolog is very good at — it is one of the reasons it’s not a language to Get Stuff Done, because input or output manipulation is a large part of any kind of serious software development. So my solution is kinda kludgy, but the bonus is that it is robust against multiple types of equipment being packed double!


The day 4 assignment is, once again, a “find all X for which Y is true” and that is what Prolog does. So the solution is, once again, very concise: two lines of code to set the requirements, one line of code to find all items that satisfy those requirements.


I’ve switched to using pastebin for the code, because most of you will probably not care and my blog is not suited for posting code anyway. And I have a busy week ahead of me, so it might be that this is as far as I go with it.


Crossposted from my blog. Comment here or at the original post.
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

fub: (Default)
fub

January 2026

S M T W T F S
    123
45678910
11121314151617
18192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 6th, 2026 09:59 am
Powered by Dreamwidth Studios