Click here to Skip to main content
16,019,132 members

Comments by NeatNet (Top 10 by date)

NeatNet 24-Feb-21 10:10am View    
Sorry, I forgot to post my code before. Now the question has it
NeatNet 24-Feb-21 10:08am View    
I just updated my question and added my code
NeatNet 24-Feb-21 10:02am View    
Deleted
volume(9,5).

program(A,B,W):-
volume(VA,VB),
A>=0,
A=<va,
b="">=0,
B=<vb,
change(a,b,[[a,b]],w),
="" write1(w).
=""
write1([]).
write1([x|l]):-
="" writeln(x),
="" write1(l).

element(a,b,w,w1):-
="" not(member([a,b],w)),
="" add1([a,b],w,w2),
="" change(a,b,w2,w1).
=""
change(3,_,w,w).
change(_,3,w,w).

change(a,b,w,w1):-
="" volume(va,_),
="" b="">0,
C is VA-A,
C>0,
min(B,C,Min),
A1 is A+Min,
B1 is B-Min,
element(A1,B1,W,W1).

change(A,B,W,W1):-
volume(_,VB),
A>0,
C is VB-B,
C>0,
min(A,C,Min),
B1 is B+Min,
A1 is A-Min,
element(A1,B1,W,W1).

change(A,B,W,W1):-
volume(VA,_),
A=VA,
B>0,
element(0,B,W,W1).

change(A,B,W,W1):-
volume(_,VB),
A>0,
B=VB,
element(A,0,W,W1).

change(A,B,W,W1):-
volume(VA,_),
A=0,
element(VA,B,W,W1).

change(A,B,W,W1):-
volume(_,VB),
B=0,
element(A,VB,W,W1).

min(A,B,A):- A=<b.
min(a,b,b):-a>B.

add(X,L,[X|L]).

add1(X,[],[X]).
add1(X,[X1|L],[X1|L1]):-
add1(X,L,L1).
NeatNet 12-Jan-21 17:10pm View    
Thanks. I will try your code
NeatNet 10-Jan-21 17:38pm View    
I did exactly that in my code and it didn't help. Local search cannot give out another correct state without knowing previous states. I think that this task has no solution, as any incorrect relocation of a ball will lead to deadend