:- prompt(_, '').
:- use_module(library(readutil)).
goal_check([]).
goal_check([[]|Xs]):-goal_check(Xs).
goal_check([[X,X,X,X]|Xs]):-goal_check(Xs).
goal_search([[Old1,Now1]|Datas1]):-goal_check(Now1).
goal_search([_|Datas1]):-goal_search(Datas1).
move_check([X,X,X,Y],[X,X,X],[Y]):-X\=Y.
move_check([X,X,Y,Y2],[X,X],[Y,Y2]):-X\=Y.
move_check([X,Y,Y2,Y3],[X],[Y,Y2,Y3]):-X\=Y.
move_check([X,X,X],[X,X,X],[]).
move_check([X,X,Y],[X,X],[Y]):-X\=Y.
move_check([X,Y,Y2],[X],[Y,Y2]):-X\=Y.
move_check([X,X],[X,X],[]).
move_check([X,Y],[X],[Y]):-X\=Y.
move_check([X],[X],[]).
move(Xs1,Res):-select(E1,Xs1,Xs2),
move_check(E1,E1Next,MoveWator),
select(E2,Xs2,Xs),
append(E1Next,E2,E2Next),
length(Ys,Len),
Len<5,
sort([E1Next,E2Next|Xs],Res).
search_all_move(Data1,Next):-member([Old1,Now1],Data1),move(Now1,Next).
main:-
process,
process:-
/* your code goes here */
Test=[[[],[[1,2,2,2],[2,1,1,1],[],[]]]],
setof(E1
,search_all_move
(Test
,E1
),Test2
),
:- main.
Oi0gc2V0X3Byb2xvZ19mbGFnKHZlcmJvc2Usc2lsZW50KS4KOi0gcHJvbXB0KF8sICcnKS4KOi0gdXNlX21vZHVsZShsaWJyYXJ5KHJlYWR1dGlsKSkuCgpnb2FsX2NoZWNrKFtdKS4KZ29hbF9jaGVjayhbW118WHNdKTotZ29hbF9jaGVjayhYcykuCmdvYWxfY2hlY2soW1tYLFgsWCxYXXxYc10pOi1nb2FsX2NoZWNrKFhzKS4KCmdvYWxfc2VhcmNoKFtbT2xkMSxOb3cxXXxEYXRhczFdKTotZ29hbF9jaGVjayhOb3cxKS4KZ29hbF9zZWFyY2goW198RGF0YXMxXSk6LWdvYWxfc2VhcmNoKERhdGFzMSkuCgptb3ZlX2NoZWNrKFtYLFgsWCxZ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