Skip to main content
Stack Overflow
  1. About
  2. For Teams
Filter by
Sorted by
Tagged with
3 votes
0 answers
168 views

Below is my code for a shortest-path solver of the well-known sliding 15 puzzle, using CLP(FD). :- use_module(library(clpfd)). % length 35 (starting position plus 34 moves), roughly 11 CPU seconds ...
brebs's user avatar
  • 4,520
3 votes
1 answer
222 views

I was using Sicstus Prolog to solve Advent of Code 2024 Day 13, and I came across a surprising discrepancy in labeling times between different instances of the same constraint model. I have: minCost(...
1 vote
1 answer
147 views

So in many cases, like: summa(X, Y, Z) :- Z #= X + Y. You can give the most general query to return a generic solution: ?-summa(X, Y, Z). $VAR(X)+ $VAR(Y)#= $VAR(Z). I have a formula involving ...
Hayato's user avatar
  • 43
0 votes
1 answer
120 views

According to the documentation (section A.9.12), CLP(FD) constraints such as #>, #=, #/\ etc. can be reified. Constraint #<==>/2 is supposed to be True iff P and Q are equivalent according ...
0 votes
1 answer
78 views

I have written a CSP program using CLP(FD) and SWI-Prolog. Some constraints look like Xi mod N #= 0, so I have to call res(Xi,Li) (with res(X,L) :- setof(X, indomain(X), L)) for each variable Xi to do ...
M.V.'s user avatar
  • 177
1 vote
1 answer
195 views

I'm working with the following SWI-Prolog version: SWI-Prolog version 9.1.2 for x86_64-linux. I'm trying to count the number of valid solutions using Prolog and the CLP(FD) module. Currently, to count ...
0 votes
0 answers
75 views

I have an arithmetic expression containing Var, and I need to match it to the following format: Step * Var + Offset If it can be represented in this form, I need to get Step and Offset values. If not, ...
2 votes
2 answers
167 views

This is a simplified example; say I want to distribute weights over tables such that the tables end up roughly equally loaded, e.g. (10 10 10 5 5) Kg can balance equally as (10 10) (10 5 5). (10 9 8 7)...
0 votes
0 answers
128 views

I'm reading The Power Of Prolog, and have got as far as the section on the Collatz sequence. I copied and pasted the code from there, adding the appropriate use_module line before... use_module(...
4 votes
1 answer
295 views

I'm learning prolog using SWI Prolog and the tutorial here. I find that if I express the collatz conjecture exactly like they do in the video, it works as long as I replace #= with is which I'm ...
2 votes
2 answers
233 views

Firstly, the clp(fd) documentation mentions: In modern Prolog systems, arithmetic constraints subsume and supersede low-level predicates over integers. The main advantage of arithmetic constraints is ...
nich's user avatar
  • 108
0 votes
2 answers
116 views

I have a prolog rule position_that_is_equals_to_two that sets X to the position at which the number 2 was found in the provided list of three elements [X, Y, Z]: position_that_is_equals_to_two([X, Y, ...
nich's user avatar
  • 108
1 vote
0 answers
127 views

I'm trying to capture a constraint variable in findall. But on the other end I get independent copies of the variable: ?- X #> 1, findall(X, (true; true), Xs), X #< 100. Xs = [_A, _B], X in 2.....
vv270's user avatar
  • 11
1 vote
1 answer
190 views

col_tri(Vars):- Vars=[X1,X2,X3], Vars in 1..3, X1#\=X2, X1#\=X3, X2#\=X3, label(Vars). This code is giving me this ...
AMINE DZ's user avatar
1 vote
2 answers
135 views

I'm trying to implement a sudoku-like puzzle solver that involves groups in prolog, and where one of the rules is that the same value cannot be repeated in the same group. My code 'works', but it ends ...

15 30 50 per page
1
2 3 4 5
...
36

AltStyle によって変換されたページ (->オリジナル) /