Advent of Code 2025

62 views
Skip to first unread message

Neng-Fa Zhou

unread,
Dec 4, 2025, 9:32:43 PM (8 days ago) Dec 4
to Picat
This year’s Advent of Code began a few days ago. I know some of you are already enjoying the puzzles with Picat. The four puzzles released so far are quite approachable. If you haven’t started yet, it’s not too late to catch up.

I’ve posted my solutions here: https://github.com/nfzhou/aoc. Let’s share our solutions and experiences.

I believe Picat is an excellent language for solving AoC puzzles. Although I don’t currently have funding to support participation using Picat, I would love to explore possibilities. If you have ideas for providing such support, similar to what Jane Street and Kotlin offer, please share them in the newsgroup.

Cheers,
Neng-Fa

Oisín Mac Fhearaí

unread,
Dec 5, 2025, 5:10:59 AM (8 days ago) Dec 5
to Picat
One of my favourite things to look forward to every year! My solutions are here: https://codeberg.org/DestyNova/advent_of_code_2025

I've been relying more and more on Picat's backtracking which allows for some really nice and tidy solutions.

Oisín

Kenneth Brown

unread,
Dec 5, 2025, 3:04:15 PM (7 days ago) Dec 5
to Picat
Really enjoying this year's problems. Here are my solutions https://github.com/siegelzero/advent2025/

Oisín Mac Fhearaí

unread,
Dec 8, 2025, 7:47:54 PM (4 days ago) Dec 8
to Picat
While solving the puzzles I implemented a couple of generic data structures/algorithms that aren't in the Picat stdlib. I've started extracting them to a new repo: https://codeberg.org/DestyNova/picat_dsa
There's not much there yet, so don't look yet if you don't want spoilers for AoC 2025 :)
Maybe in future we can move some of them (and/or reimplement them more efficiently) to the standard Picat distribution?

Neng-Fa Zhou

unread,
Dec 9, 2025, 12:06:41 PM (3 days ago) Dec 9
to Oisín Mac Fhearaí, Picat
That's a great idea. Let's expand the util module and invite people to contribute after AOC'26 ends.

Cheers,
NF

--
You received this message because you are subscribed to the Google Groups "Picat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picat-lang+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/picat-lang/51978c43-b068-4bb6-a8b0-9d0458f1c8cdn%40googlegroups.com.

Neng-Fa Zhou

unread,
Dec 10, 2025, 6:17:48 PM (2 days ago) Dec 10
to Picat
Today is a happy day for Picat in this year’s AoC: the Day 10 problem really showcases Picat’s strengths in tabling and constraint solving. I solved Part 1 easily using tabling, but applying the same approach to Part 2 turned out to be too time-consuming. After formulating a COP model using SAT, I was able to solve it!

https://github.com/nfzhou/aoc/blob/main/aoc_25_10_part1.pi
https://github.com/nfzhou/aoc/blob/main/aoc_25_10_part2.pi

Cheers,
NF

Oisín Mac Fhearaí

unread,
Dec 10, 2025, 11:52:53 PM (2 days ago) Dec 10
to Neng-Fa Zhou, Picat
I solved part 1 using the planner, but it was too slow for part 2 (and doing too much work, since the ordering of button presses doesn't matter in the problem). After a while I got a SAT formulation working which produced the correct answer in about a minute. Amazingly, I then tried the "mip" module with the GLPK solver option, which produced the correct answer in 0.9 seconds!

C. G.

unread,
Dec 11, 2025, 10:57:19 AM (yesterday) Dec 11
to Picat
Here are my solutions: https://github.com/cgrozea/AdventOfCode2025-Picat
I compete with Oisin (DestyNova) on the leaderboard from the last year - he is faster and also explains his solutions, but now and then one of my solutions is simpler or runs faster, so it is potentially interesting to look at them.

C.G.

Peter Bernschneider

unread,
Dec 11, 2025, 12:50:22 PM (yesterday) Dec 11
to Picat
Day11 also is perfect for Picat! See Link

Oisín Mac Fhearaí

unread,
Dec 11, 2025, 1:20:51 PM (yesterday) Dec 11
to Peter Bernschneider, Picat
Peter, your code is very clear, concise and effective.
I still have to study some of Cristian's clever tabling solutions from last year; it seemed like you were able to very quickly solve problems just using tabling, where I tried the planner with little success.

Thanks all for sharing your solutions! I always learn something new from everyone's different approaches. Today I wasted a lot of time trying to bottom-up DP but eventually went back to tabling and got it to work.


C. G.

unread,
Dec 11, 2025, 2:37:28 PM (yesterday) Dec 11
to Picat
I agree, the code of Peter for problem 11 is really nice.

Neng-Fa Zhou

unread,
Dec 11, 2025, 4:21:55 PM (yesterday) Dec 11
to Picat
Here is my solution to the day-11 part-2 problem:


It follows the same idea as Peter's, but it runs ten times faster because it represents device names as atoms rather than strings, and it uses the nt mode to avoid tabling the graph. 

Cheers,
NF

Neng-Fa Zhou

unread,
4:42 PM (6 hours ago) 4:42 PM
to Picat
As expected, the day-12 problem is brutal. Here is my first attempt to formulate it as a CSP for sat:


It works for the example instance but is unable to pack presents in any region (it takes too long to even  generate constraints). 

Cheers,
NF

C. G.

unread,
8:25 PM (2 hours ago) 8:25 PM
to Picat
Hi NF,

The problem would have been brutal weren't for the too easy instances proposed (both the positive and the negative ones). Anyway, I also tried to solve it truly for the general case with constraints and SAT solver in Picat: https://github.com/cgrozea/AdventOfCode2025-Picat/blob/main/day12/part1.pi

My version works, it takes some minutes per instance. Just for fun (and having access to a machine with a lot of RAM) I tried after the fact to ran it with parallelism 50 (one instance per call), and thus in a few hours it solved the 1000 instances but for 15, which exceeded Picat stack+heap area size. I've tried for one of those to call Picat with -s and to give it 20 GB, it seemed interestingly to build the model faster (fewer GCs I guess) and then got to solving it.

What I find interesting, after realising that all instances are easy, is that my modelling leads to instantaneous refutation of the instances without solution, but requires several minutes for equally easy instances for which trivial solution exist. I thought I'll just change the variable search mode to random or something like this, to "spread" the translations, but the solve prredicatr for sat doesn't seem to have this sort of option, only cp - and cp was very slow even on the smaller examples from the text of the problem.
So I'm left wondering, how to model or call the solver in such a way that also the trivial positive instances are also quickly solved by the solver, not only the negative ones.

best regards,
CG

Oisín Mac Fhearaí

unread,
8:25 PM (2 hours ago) 8:25 PM
to Neng-Fa Zhou, Picat
Day 12 was very frustrating. I also tried a SAT formulation first, and it works for the example but takes maybe 10-15 minutes or more per line of the real data. It was also extremely painful to produce a working SAT program this time...
I also tried a planner solution but it got stuck in the same place. As is often the case when (misusing) the planner for this type of problem, the order of placing pieces doesn't matter, so the planner is probably an inappropriate tool.

Someone gave me a hint that caused me to visit something I tried earlier that does NOT work for the sample data, but allows a completely trivial (but *very* unsatisfying) solution to the full input. I'd like to revisit this one and "properly" solve the general case!

--
You received this message because you are subscribed to the Google Groups "Picat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picat-lang+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages