Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advent of Code 2024 Day 8 in Trealla Prolog #643

Open
Jean-Luc-Picard-2021 opened this issue Dec 8, 2024 · 1 comment
Open

Advent of Code 2024 Day 8 in Trealla Prolog #643

Jean-Luc-Picard-2021 opened this issue Dec 8, 2024 · 1 comment

Comments

@Jean-Luc-Picard-2021
Copy link

Jean-Luc-Picard-2021 commented Dec 8, 2024

How would one implement Advent of Code 2024 Day 8:

Day 8: Resonant Collinearity
https://adventofcode.com/2024/day/8

In Trealla Prolog? Whats the recommended way to solve it?
It specifies as the counting of unique solutions:

How many unique locations within the bounds of the map contain an antinode?

@Jean-Luc-Picard-2021
Copy link
Author

Ok, I found a solution without aggregate_all/3 or distinct/1,
just using some other common builtins:

count_distinct(G, N) :- 
   findall(G, G, L),
   sort(L, R),
   length(R, N).

But the above uses more memory usually, since findall/3
would create the non-deduplicated list first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant