% -----------------------------------------
% Exercice 1
% @author "Alexis Fouché" <contact@alexisfouche.net>
% -----------------------------------------

% == Question
chiffre(0).
chiffre(1).
chiffre(2).
chiffre(3).
chiffre(4).
chiffre(5).
chiffre(6).
chiffre(7).
chiffre(8).
chiffre(9).

retenue(0).
retenue(1).

cryptarith([L,O,G,I,C], [L,O,G,I,C], [P,R,O,L,O,G]) :-
    chiffre(L),
    chiffre(O),
    chiffre(G),
    chiffre(I),
    chiffre(C),
    chiffre(R),
    chiffre(P),

    L \= 0, P \= 0,
    R \= L, R \= P,
    O \= L, O \= R,
    G \= O, G \= L, G \= R,
    I \= G, I \= O, I \= L, I \= R,
    C \= I, C \= G, C \= O, C \= L, C \= R,

    retenue(R1),
    retenue(R2),
    retenue(R3),
    retenue(R4),

    L + L + R4 =:= R + 10*P,
    O + O + R3 =:= O + (R4*10),
    G + G + R2 =:= L + (R3*10),
    I + I + R1 =:= O + (R2*10),
    C + C =:= G + (R1*10).

