% File : sudoku368.pl % Author : N.-F. ZHOU and K. Akama % Date : 1996 go:- statistics(runtime,[S|_]), vars(Vars), gosub(Vars), statistics(runtime,[E|_]), T is E-S, write(T), write(' milliseconds'). gosub(Vars):- reverse(Vars,Vars1), labeling([ff],Vars1), display_board(Vars). gosub(Vars). vars(Vars):- Vars=[A11,A12,A13,A14,A15,B11,B12,B13,B14,B15,C11,C12,C13,C14,C15, D11,D12,D13,D14,D15,E11,E12,E13,E14,E15, A21,A22,A23,A24,A25,B21,B22,B23,B24,B25,C21,C22,C23,C24,C25, D21,D22,D23,D24,D25,E21,E22,E23,E24,E25, A31,A32,A33,A34,A35,B31,B32,B33,B34,B35,C31,C32,C33,C34,C35, D31,D32,D33,D34,D35,E31,E32,E33,E34,E35, A41,A42,A43,A44,A45,B41,B42,B43,B44,B45,C41,C42,C43,C44,C45, D41,D42,D43,D44,D45,E41,E42,E43,E44,E45, A51,A52,A53,A54,A55,B51,B52,B53,B54,B55,C51,C52,C53,C54,C55, D51,D52,D53,D54,D55,E51,E52,E53,E54,E55, F11,F12,F13,F14,F15,G11,G12,G13,G14,G15,H11,H12,H13,H14,H15, I11,I12,I13,I14,I15,J11,J12,J13,J14,J15, F21,F22,F23,F24,F25,G21,G22,G23,G24,G25,H21,H22,H23,H24,H25, I21,I22,I23,I24,I25,J21,J22,J23,J24,J25, F31,F32,F33,F34,F35,G31,G32,G33,G34,G35,H31,H32,H33,H34,H35, I31,I32,I33,I34,I35,J31,J32,J33,J34,J35, F41,F42,F43,F44,F45,G41,G42,G43,G44,G45,H41,H42,H43,H44,H45, I41,I42,I43,I44,I45,J41,J42,J43,J44,J45, F51,F52,F53,F54,F55,G51,G52,G53,G54,G55,H51,H52,H53,H54,H55, I51,I52,I53,I54,I55,J51,J52,J53,J54,J55, K11,K12,K13,K14,K15,L11,L12,L13,L14,L15,M11,M12,M13,M14,M15, N11,N12,N13,N14,N15,O11,O12,O13,O14,O15, K21,K22,K23,K24,K25,L21,L22,L23,L24,L25,M21,M22,M23,M24,M25, N21,N22,N23,N24,N25,O21,O22,O23,O24,O25, K31,K32,K33,K34,K35,L31,L32,L33,L34,L35,M31,M32,M33,M34,M35, N31,N32,N33,N34,N35,O31,O32,O33,O34,O35, K41,K42,K43,K44,K45,L41,L42,L43,L44,L45,M41,M42,M43,M44,M45, N41,N42,N43,N44,N45,O41,O42,O43,O44,O45, K51,K52,K53,K54,K55,L51,L52,L53,L54,L55,M51,M52,M53,M54,M55, N51,N52,N53,N54,N55,O51,O52,O53,O54,O55, P11,P12,P13,P14,P15,Q11,Q12,Q13,Q14,Q15,R11,R12,R13,R14,R15, S11,S12,S13,S14,S15,T11,T12,T13,T14,T15, P21,P22,P23,P24,P25,Q21,Q22,Q23,Q24,Q25,R21,R22,R23,R24,R25, S21,S22,S23,S24,S25,T21,T22,T23,T24,T25, P31,P32,P33,P34,P35,Q31,Q32,Q33,Q34,Q35,R31,R32,R33,R34,R35, S31,S32,S33,S34,S35,T31,T32,T33,T34,T35, P41,P42,P43,P44,P45,Q41,Q42,Q43,Q44,Q45,R41,R42,R43,R44,R45, S41,S42,S43,S44,S45,T41,T42,T43,T44,T45, P51,P52,P53,P54,P55,Q51,Q52,Q53,Q54,Q55,R51,R52,R53,R54,R55, S51,S52,S53,S54,S55,T51,T52,T53,T54,T55, U11,U12,U13,U14,U15,V11,V12,V13,V14,V15,W11,W12,W13,W14,W15, X11,X12,X13,X14,X15,Y11,Y12,Y13,Y14,Y15, U21,U22,U23,U24,U25,V21,V22,V23,V24,V25,W21,W22,W23,W24,W25, X21,X22,X23,X24,X25,Y21,Y22,Y23,Y24,Y25, U31,U32,U33,U34,U35,V31,V32,V33,V34,V35,W31,W32,W33,W34,W35, X31,X32,X33,X34,X35,Y31,Y32,Y33,Y34,Y35, U41,U42,U43,U44,U45,V41,V42,V43,V44,V45,W41,W42,W43,W44,W45, X41,X42,X43,X44,X45,Y41,Y42,Y43,Y44,Y45, U51,U52,U53,U54,U55,V51,V52,V53,V54,V55,W51,W52,W53,W54,W55, X51,X52,X53,X54,X55,Y51,Y52,Y53,Y54,Y55], domain(Vars,0,24), A11#=2,A12#=1,A14#=13,B11#=0,B15#=10,C12#=12,D13#=6,D15#=15,E11#=14,E13#=20,E14#=8,A25#=24,B21#=20,B22#=11,C21#=16,C24#=6,D21#=21,E22#=17,E25#=1,A32#=21,A33#=9,A35#=10,B31#=4,B34#=12,C33#=11,C35#=22,D33#=2,A41#=6,A43#=3,A44#=16,B41#=13,B44#=5,C43#=21,C44#=23,C45#=10,D41#=11,D42#=14,D43#=8,E42#=24,E45#=7,A51#=8,A54#=20,A55#=22,B51#=16,B54#=3,C52#=5,D53#=18,D54#=4,D55#=24,E52#=10,E53#=0,F12#=23,F14#=9,G11#=12,H11#=14,H13#=8,H14#=22,H15#=20,I15#=13,J14#=15,F24#=14,G21#=3,G24#=19,H23#=2,H25#=13,I21#=18,I22#=7,I25#=4,G33#=17,G34#=1,G35#=13,H31#=9,I34#=14,J32#=4,J33#=12,F42#=2,G42#=23,G43#=10,G44#=21,H42#=7,H44#=24,I42#=19,I45#=16,J44#=22,J45#=8,F52#=18,F55#=4,G54#=11,H51#=3,H53#=6,H54#=15,H55#=16,I53#=10,J51#=1,J53#=5,K12#=3,K13#=16,K14#=15,L11#=17,L12#=5,M12#=0,M15#=23,N14#=22,O11#=4,O13#=24,O14#=7,K22#=12,K24#=24,L21#=22,L22#=14,L25#=8,M22#=16,M23#=3,M25#=6,N21#=9,O21#=13,O22#=2,O23#=17,K31#=1,K32#=5,K33#=13,L31#=10,L32#=9,L33#=21,M35#=18,N31#=3,O31#=20,O32#=8,K43#=0,K44#=10,K45#=23,L44#=4,L45#=18,M44#=11,N43#=1,N44#=17,N45#=2,O42#=6,O43#=15,O44#=19,O45#=3,K51#=11,K52#=14,K53#=20,K54#=22,L51#=15,L55#=6,M52#=13,M54#=1,N51#=12,N53#=7,O51#=0,O53#=10,O55#=9,P12#=15,Q13#=13,Q14#=2,R12#=23,R15#=9,S13#=20,S15#=14,Q22#=15,R23#=17,R24#=13,S22#=18,S25#=12,T23#=21,T25#=10,P31#=0,Q31#=7,Q34#=18,R31#=11,R33#=22,R35#=14,S35#=5,T31#=6,T34#=16,T35#=15,P44#=1,P45#=5,Q43#=0,Q44#=23,Q45#=9,R41#=7,R43#=24,S42#=6,S44#=19,P54#=7,Q52#=22,Q53#=20,Q54#=8,Q55#=14,R51#=19,R55#=3,S52#=23,S53#=0,T53#=1,T55#=17,U15#=11,V11#=6,V13#=3,V15#=19,W11#=2,W12#=17,W14#=5,X14#=18,Y12#=21,Y14#=9,U22#=16,U23#=15,U24#=6,U25#=19,V21#=2,V25#=1,W23#=0,W24#=9,X22#=22,X25#=11,Y23#=18,Y24#=12,Y25#=4,U33#=10,V31#=18,V33#=12,V35#=7,W31#=8,W33#=20,X32#=17,X33#=5,X34#=2,Y31#=15,Y32#=19,Y33#=6,Y34#=3,U43#=17,V43#=9,W41#=18,W42#=24,W43#=4,W44#=12,X41#=16,X42#=15,X43#=3,X45#=19,Y42#=11,Y45#=20,U53#=24,U55#=7,V51#=8,V52#=20,V55#=11,W52#=15,X51#=0,X52#=10,X54#=23,X55#=21,Y55#=13, % block all_distinct([A11,A12,A13,A14,A15,A21,A22,A23,A24,A25,A31,A32,A33,A34,A35,A41,A42,A43,A44,A45,A51,A52,A53,A54,A55]), all_distinct([B11,B12,B13,B14,B15,B21,B22,B23,B24,B25,B31,B32,B33,B34,B35,B41,B42,B43,B44,B45,B51,B52,B53,B54,B55]), all_distinct([C11,C12,C13,C14,C15,C21,C22,C23,C24,C25,C31,C32,C33,C34,C35,C41,C42,C43,C44,C45,C51,C52,C53,C54,C55]), all_distinct([D11,D12,D13,D14,D15,D21,D22,D23,D24,D25,D31,D32,D33,D34,D35,D41,D42,D43,D44,D45,D51,D52,D53,D54,D55]), all_distinct([E11,E12,E13,E14,E15,E21,E22,E23,E24,E25,E31,E32,E33,E34,E35,E41,E42,E43,E44,E45,E51,E52,E53,E54,E55]), all_distinct([F11,F12,F13,F14,F15,F21,F22,F23,F24,F25,F31,F32,F33,F34,F35,F41,F42,F43,F44,F45,F51,F52,F53,F54,F55]), all_distinct([G11,G12,G13,G14,G15,G21,G22,G23,G24,G25,G31,G32,G33,G34,G35,G41,G42,G43,G44,G45,G51,G52,G53,G54,G55]), all_distinct([H11,H12,H13,H14,H15,H21,H22,H23,H24,H25,H31,H32,H33,H34,H35,H41,H42,H43,H44,H45,H51,H52,H53,H54,H55]), all_distinct([I11,I12,I13,I14,I15,I21,I22,I23,I24,I25,I31,I32,I33,I34,I35,I41,I42,I43,I44,I45,I51,I52,I53,I54,I55]), all_distinct([J11,J12,J13,J14,J15,J21,J22,J23,J24,J25,J31,J32,J33,J34,J35,J41,J42,J43,J44,J45,J51,J52,J53,J54,J55]), all_distinct([K11,K12,K13,K14,K15,K21,K22,K23,K24,K25,K31,K32,K33,K34,K35,K41,K42,K43,K44,K45,K51,K52,K53,K54,K55]), all_distinct([L11,L12,L13,L14,L15,L21,L22,L23,L24,L25,L31,L32,L33,L34,L35,L41,L42,L43,L44,L45,L51,L52,L53,L54,L55]), all_distinct([M11,M12,M13,M14,M15,M21,M22,M23,M24,M25,M31,M32,M33,M34,M35,M41,M42,M43,M44,M45,M51,M52,M53,M54,M55]), all_distinct([N11,N12,N13,N14,N15,N21,N22,N23,N24,N25,N31,N32,N33,N34,N35,N41,N42,N43,N44,N45,N51,N52,N53,N54,N55]), all_distinct([O11,O12,O13,O14,O15,O21,O22,O23,O24,O25,O31,O32,O33,O34,O35,O41,O42,O43,O44,O45,O51,O52,O53,O54,O55]), all_distinct([P11,P12,P13,P14,P15,P21,P22,P23,P24,P25,P31,P32,P33,P34,P35,P41,P42,P43,P44,P45,P51,P52,P53,P54,P55]), all_distinct([Q11,Q12,Q13,Q14,Q15,Q21,Q22,Q23,Q24,Q25,Q31,Q32,Q33,Q34,Q35,Q41,Q42,Q43,Q44,Q45,Q51,Q52,Q53,Q54,Q55]), all_distinct([R11,R12,R13,R14,R15,R21,R22,R23,R24,R25,R31,R32,R33,R34,R35,R41,R42,R43,R44,R45,R51,R52,R53,R54,R55]), all_distinct([S11,S12,S13,S14,S15,S21,S22,S23,S24,S25,S31,S32,S33,S34,S35,S41,S42,S43,S44,S45,S51,S52,S53,S54,S55]), all_distinct([T11,T12,T13,T14,T15,T21,T22,T23,T24,T25,T31,T32,T33,T34,T35,T41,T42,T43,T44,T45,T51,T52,T53,T54,T55]), all_distinct([U11,U12,U13,U14,U15,U21,U22,U23,U24,U25,U31,U32,U33,U34,U35,U41,U42,U43,U44,U45,U51,U52,U53,U54,U55]), all_distinct([V11,V12,V13,V14,V15,V21,V22,V23,V24,V25,V31,V32,V33,V34,V35,V41,V42,V43,V44,V45,V51,V52,V53,V54,V55]), all_distinct([W11,W12,W13,W14,W15,W21,W22,W23,W24,W25,W31,W32,W33,W34,W35,W41,W42,W43,W44,W45,W51,W52,W53,W54,W55]), all_distinct([X11,X12,X13,X14,X15,X21,X22,X23,X24,X25,X31,X32,X33,X34,X35,X41,X42,X43,X44,X45,X51,X52,X53,X54,X55]), all_distinct([Y11,Y12,Y13,Y14,Y15,Y21,Y22,Y23,Y24,Y25,Y31,Y32,Y33,Y34,Y35,Y41,Y42,Y43,Y44,Y45,Y51,Y52,Y53,Y54,Y55]), % horizontal all_distinct([A11,A12,A13,A14,A15,B11,B12,B13,B14,B15,C11,C12,C13,C14,C15,D11,D12,D13,D14,D15,E11,E12,E13,E14,E15]), all_distinct([A21,A22,A23,A24,A25,B21,B22,B23,B24,B25,C21,C22,C23,C24,C25,D21,D22,D23,D24,D25,E21,E22,E23,E24,E25]), all_distinct([A31,A32,A33,A34,A35,B31,B32,B33,B34,B35,C31,C32,C33,C34,C35,D31,D32,D33,D34,D35,E31,E32,E33,E34,E35]), all_distinct([A41,A42,A43,A44,A45,B41,B42,B43,B44,B45,C41,C42,C43,C44,C45,D41,D42,D43,D44,D45,E41,E42,E43,E44,E45]), all_distinct([A51,A52,A53,A54,A55,B51,B52,B53,B54,B55,C51,C52,C53,C54,C55,D51,D52,D53,D54,D55,E51,E52,E53,E54,E55]), all_distinct([F11,F12,F13,F14,F15,G11,G12,G13,G14,G15,H11,H12,H13,H14,H15,I11,I12,I13,I14,I15,J11,J12,J13,J14,J15]), all_distinct([F21,F22,F23,F24,F25,G21,G22,G23,G24,G25,H21,H22,H23,H24,H25,I21,I22,I23,I24,I25,J21,J22,J23,J24,J25]), all_distinct([F31,F32,F33,F34,F35,G31,G32,G33,G34,G35,H31,H32,H33,H34,H35,I31,I32,I33,I34,I35,J31,J32,J33,J34,J35]), all_distinct([F41,F42,F43,F44,F45,G41,G42,G43,G44,G45,H41,H42,H43,H44,H45,I41,I42,I43,I44,I45,J41,J42,J43,J44,J45]), all_distinct([F51,F52,F53,F54,F55,G51,G52,G53,G54,G55,H51,H52,H53,H54,H55,I51,I52,I53,I54,I55,J51,J52,J53,J54,J55]), all_distinct([K11,K12,K13,K14,K15,L11,L12,L13,L14,L15,M11,M12,M13,M14,M15,N11,N12,N13,N14,N15,O11,O12,O13,O14,O15]), all_distinct([K21,K22,K23,K24,K25,L21,L22,L23,L24,L25,M21,M22,M23,M24,M25,N21,N22,N23,N24,N25,O21,O22,O23,O24,O25]), all_distinct([K31,K32,K33,K34,K35,L31,L32,L33,L34,L35,M31,M32,M33,M34,M35,N31,N32,N33,N34,N35,O31,O32,O33,O34,O35]), all_distinct([K41,K42,K43,K44,K45,L41,L42,L43,L44,L45,M41,M42,M43,M44,M45,N41,N42,N43,N44,N45,O41,O42,O43,O44,O45]), all_distinct([K51,K52,K53,K54,K55,L51,L52,L53,L54,L55,M51,M52,M53,M54,M55,N51,N52,N53,N54,N55,O51,O52,O53,O54,O55]), all_distinct([P11,P12,P13,P14,P15,Q11,Q12,Q13,Q14,Q15,R11,R12,R13,R14,R15,S11,S12,S13,S14,S15,T11,T12,T13,T14,T15]), all_distinct([P21,P22,P23,P24,P25,Q21,Q22,Q23,Q24,Q25,R21,R22,R23,R24,R25,S21,S22,S23,S24,S25,T21,T22,T23,T24,T25]), all_distinct([P31,P32,P33,P34,P35,Q31,Q32,Q33,Q34,Q35,R31,R32,R33,R34,R35,S31,S32,S33,S34,S35,T31,T32,T33,T34,T35]), all_distinct([P41,P42,P43,P44,P45,Q41,Q42,Q43,Q44,Q45,R41,R42,R43,R44,R45,S41,S42,S43,S44,S45,T41,T42,T43,T44,T45]), all_distinct([P51,P52,P53,P54,P55,Q51,Q52,Q53,Q54,Q55,R51,R52,R53,R54,R55,S51,S52,S53,S54,S55,T51,T52,T53,T54,T55]), all_distinct([U11,U12,U13,U14,U15,V11,V12,V13,V14,V15,W11,W12,W13,W14,W15,X11,X12,X13,X14,X15,Y11,Y12,Y13,Y14,Y15]), all_distinct([U21,U22,U23,U24,U25,V21,V22,V23,V24,V25,W21,W22,W23,W24,W25,X21,X22,X23,X24,X25,Y21,Y22,Y23,Y24,Y25]), all_distinct([U31,U32,U33,U34,U35,V31,V32,V33,V34,V35,W31,W32,W33,W34,W35,X31,X32,X33,X34,X35,Y31,Y32,Y33,Y34,Y35]), all_distinct([U41,U42,U43,U44,U45,V41,V42,V43,V44,V45,W41,W42,W43,W44,W45,X41,X42,X43,X44,X45,Y41,Y42,Y43,Y44,Y45]), all_distinct([U51,U52,U53,U54,U55,V51,V52,V53,V54,V55,W51,W52,W53,W54,W55,X51,X52,X53,X54,X55,Y51,Y52,Y53,Y54,Y55]), % vertical all_distinct([A11,A21,A31,A41,A51,F11,F21,F31,F41,F51,K11,K21,K31,K41,K51,P11,P21,P31,P41,P51,U11,U21,U31,U41,U51]), all_distinct([A12,A22,A32,A42,A52,F12,F22,F32,F42,F52,K12,K22,K32,K42,K52,P12,P22,P32,P42,P52,U12,U22,U32,U42,U52]), all_distinct([A13,A23,A33,A43,A53,F13,F23,F33,F43,F53,K13,K23,K33,K43,K53,P13,P23,P33,P43,P53,U13,U23,U33,U43,U53]), all_distinct([A14,A24,A34,A44,A54,F14,F24,F34,F44,F54,K14,K24,K34,K44,K54,P14,P24,P34,P44,P54,U14,U24,U34,U44,U54]), all_distinct([A15,A25,A35,A45,A55,F15,F25,F35,F45,F55,K15,K25,K35,K45,K55,P15,P25,P35,P45,P55,U15,U25,U35,U45,U55]), all_distinct([B11,B21,B31,B41,B51,G11,G21,G31,G41,G51,L11,L21,L31,L41,L51,Q11,Q21,Q31,Q41,Q51,V11,V21,V31,V41,V51]), all_distinct([B12,B22,B32,B42,B52,G12,G22,G32,G42,G52,L12,L22,L32,L42,L52,Q12,Q22,Q32,Q42,Q52,V12,V22,V32,V42,V52]), all_distinct([B13,B23,B33,B43,B53,G13,G23,G33,G43,G53,L13,L23,L33,L43,L53,Q13,Q23,Q33,Q43,Q53,V13,V23,V33,V43,V53]), all_distinct([B14,B24,B34,B44,B54,G14,G24,G34,G44,G54,L14,L24,L34,L44,L54,Q14,Q24,Q34,Q44,Q54,V14,V24,V34,V44,V54]), all_distinct([B15,B25,B35,B45,B55,G15,G25,G35,G45,G55,L15,L25,L35,L45,L55,Q15,Q25,Q35,Q45,Q55,V15,V25,V35,V45,V55]), all_distinct([C11,C21,C31,C41,C51,H11,H21,H31,H41,H51,M11,M21,M31,M41,M51,R11,R21,R31,R41,R51,W11,W21,W31,W41,W51]), all_distinct([C12,C22,C32,C42,C52,H12,H22,H32,H42,H52,M12,M22,M32,M42,M52,R12,R22,R32,R42,R52,W12,W22,W32,W42,W52]), all_distinct([C13,C23,C33,C43,C53,H13,H23,H33,H43,H53,M13,M23,M33,M43,M53,R13,R23,R33,R43,R53,W13,W23,W33,W43,W53]), all_distinct([C14,C24,C34,C44,C54,H14,H24,H34,H44,H54,M14,M24,M34,M44,M54,R14,R24,R34,R44,R54,W14,W24,W34,W44,W54]), all_distinct([C15,C25,C35,C45,C55,H15,H25,H35,H45,H55,M15,M25,M35,M45,M55,R15,R25,R35,R45,R55,W15,W25,W35,W45,W55]), all_distinct([D11,D21,D31,D41,D51,I11,I21,I31,I41,I51,N11,N21,N31,N41,N51,S11,S21,S31,S41,S51,X11,X21,X31,X41,X51]), all_distinct([D12,D22,D32,D42,D52,I12,I22,I32,I42,I52,N12,N22,N32,N42,N52,S12,S22,S32,S42,S52,X12,X22,X32,X42,X52]), all_distinct([D13,D23,D33,D43,D53,I13,I23,I33,I43,I53,N13,N23,N33,N43,N53,S13,S23,S33,S43,S53,X13,X23,X33,X43,X53]), all_distinct([D14,D24,D34,D44,D54,I14,I24,I34,I44,I54,N14,N24,N34,N44,N54,S14,S24,S34,S44,S54,X14,X24,X34,X44,X54]), all_distinct([D15,D25,D35,D45,D55,I15,I25,I35,I45,I55,N15,N25,N35,N45,N55,S15,S25,S35,S45,S55,X15,X25,X35,X45,X55]), all_distinct([E11,E21,E31,E41,E51,J11,J21,J31,J41,J51,O11,O21,O31,O41,O51,T11,T21,T31,T41,T51,Y11,Y21,Y31,Y41,Y51]), all_distinct([E12,E22,E32,E42,E52,J12,J22,J32,J42,J52,O12,O22,O32,O42,O52,T12,T22,T32,T42,T52,Y12,Y22,Y32,Y42,Y52]), all_distinct([E13,E23,E33,E43,E53,J13,J23,J33,J43,J53,O13,O23,O33,O43,O53,T13,T23,T33,T43,T53,Y13,Y23,Y33,Y43,Y53]), all_distinct([E14,E24,E34,E44,E54,J14,J24,J34,J44,J54,O14,O24,O34,O44,O54,T14,T24,T34,T44,T54,Y14,Y24,Y34,Y44,Y54]), all_distinct([E15,E25,E35,E45,E55,J15,J25,J35,J45,J55,O15,O25,O35,O45,O55,T15,T25,T35,T45,T55,Y15,Y25,Y35,Y45,Y55]). display_board([A11,A12,A13,A14,A15,B11,B12,B13,B14,B15,C11,C12,C13,C14,C15, D11,D12,D13,D14,D15,E11,E12,E13,E14,E15, A21,A22,A23,A24,A25,B21,B22,B23,B24,B25,C21,C22,C23,C24,C25, D21,D22,D23,D24,D25,E21,E22,E23,E24,E25, A31,A32,A33,A34,A35,B31,B32,B33,B34,B35,C31,C32,C33,C34,C35, D31,D32,D33,D34,D35,E31,E32,E33,E34,E35, A41,A42,A43,A44,A45,B41,B42,B43,B44,B45,C41,C42,C43,C44,C45, D41,D42,D43,D44,D45,E41,E42,E43,E44,E45, A51,A52,A53,A54,A55,B51,B52,B53,B54,B55,C51,C52,C53,C54,C55, D51,D52,D53,D54,D55,E51,E52,E53,E54,E55, F11,F12,F13,F14,F15,G11,G12,G13,G14,G15,H11,H12,H13,H14,H15, I11,I12,I13,I14,I15,J11,J12,J13,J14,J15, F21,F22,F23,F24,F25,G21,G22,G23,G24,G25,H21,H22,H23,H24,H25, I21,I22,I23,I24,I25,J21,J22,J23,J24,J25, F31,F32,F33,F34,F35,G31,G32,G33,G34,G35,H31,H32,H33,H34,H35, I31,I32,I33,I34,I35,J31,J32,J33,J34,J35, F41,F42,F43,F44,F45,G41,G42,G43,G44,G45,H41,H42,H43,H44,H45, I41,I42,I43,I44,I45,J41,J42,J43,J44,J45, F51,F52,F53,F54,F55,G51,G52,G53,G54,G55,H51,H52,H53,H54,H55, I51,I52,I53,I54,I55,J51,J52,J53,J54,J55, K11,K12,K13,K14,K15,L11,L12,L13,L14,L15,M11,M12,M13,M14,M15, N11,N12,N13,N14,N15,O11,O12,O13,O14,O15, K21,K22,K23,K24,K25,L21,L22,L23,L24,L25,M21,M22,M23,M24,M25, N21,N22,N23,N24,N25,O21,O22,O23,O24,O25, K31,K32,K33,K34,K35,L31,L32,L33,L34,L35,M31,M32,M33,M34,M35, N31,N32,N33,N34,N35,O31,O32,O33,O34,O35, K41,K42,K43,K44,K45,L41,L42,L43,L44,L45,M41,M42,M43,M44,M45, N41,N42,N43,N44,N45,O41,O42,O43,O44,O45, K51,K52,K53,K54,K55,L51,L52,L53,L54,L55,M51,M52,M53,M54,M55, N51,N52,N53,N54,N55,O51,O52,O53,O54,O55, P11,P12,P13,P14,P15,Q11,Q12,Q13,Q14,Q15,R11,R12,R13,R14,R15, S11,S12,S13,S14,S15,T11,T12,T13,T14,T15, P21,P22,P23,P24,P25,Q21,Q22,Q23,Q24,Q25,R21,R22,R23,R24,R25, S21,S22,S23,S24,S25,T21,T22,T23,T24,T25, P31,P32,P33,P34,P35,Q31,Q32,Q33,Q34,Q35,R31,R32,R33,R34,R35, S31,S32,S33,S34,S35,T31,T32,T33,T34,T35, P41,P42,P43,P44,P45,Q41,Q42,Q43,Q44,Q45,R41,R42,R43,R44,R45, S41,S42,S43,S44,S45,T41,T42,T43,T44,T45, P51,P52,P53,P54,P55,Q51,Q52,Q53,Q54,Q55,R51,R52,R53,R54,R55, S51,S52,S53,S54,S55,T51,T52,T53,T54,T55, U11,U12,U13,U14,U15,V11,V12,V13,V14,V15,W11,W12,W13,W14,W15, X11,X12,X13,X14,X15,Y11,Y12,Y13,Y14,Y15, U21,U22,U23,U24,U25,V21,V22,V23,V24,V25,W21,W22,W23,W24,W25, X21,X22,X23,X24,X25,Y21,Y22,Y23,Y24,Y25, U31,U32,U33,U34,U35,V31,V32,V33,V34,V35,W31,W32,W33,W34,W35, X31,X32,X33,X34,X35,Y31,Y32,Y33,Y34,Y35, U41,U42,U43,U44,U45,V41,V42,V43,V44,V45,W41,W42,W43,W44,W45, X41,X42,X43,X44,X45,Y41,Y42,Y43,Y44,Y45, U51,U52,U53,U54,U55,V51,V52,V53,V54,V55,W51,W52,W53,W54,W55, X51,X52,X53,X54,X55,Y51,Y52,Y53,Y54,Y55]):- write_line([A11,A12,A13,A14,A15,B11,B12,B13,B14,B15,C11,C12,C13,C14,C15, D11,D12,D13,D14,D15,E11,E12,E13,E14,E15]),nl, write_line([A21,A22,A23,A24,A25,B21,B22,B23,B24,B25,C21,C22,C23,C24,C25, D21,D22,D23,D24,D25,E21,E22,E23,E24,E25]),nl, write_line([A31,A32,A33,A34,A35,B31,B32,B33,B34,B35,C31,C32,C33,C34,C35, D31,D32,D33,D34,D35,E31,E32,E33,E34,E35]),nl, write_line([A41,A42,A43,A44,A45,B41,B42,B43,B44,B45,C41,C42,C43,C44,C45, D41,D42,D43,D44,D45,E41,E42,E43,E44,E45]),nl, write_line([A51,A52,A53,A54,A55,B51,B52,B53,B54,B55,C51,C52,C53,C54,C55, D51,D52,D53,D54,D55,E51,E52,E53,E54,E55]),nl, write_line([F11,F12,F13,F14,F15,G11,G12,G13,G14,G15,H11,H12,H13,H14,H15, I11,I12,I13,I14,I15,J11,J12,J13,J14,J15]),nl, write_line([F21,F22,F23,F24,F25,G21,G22,G23,G24,G25,H21,H22,H23,H24,H25, I21,I22,I23,I24,I25,J21,J22,J23,J24,J25]),nl, write_line([F31,F32,F33,F34,F35,G31,G32,G33,G34,G35,H31,H32,H33,H34,H35, I31,I32,I33,I34,I35,J31,J32,J33,J34,J35]),nl, write_line([F41,F42,F43,F44,F45,G41,G42,G43,G44,G45,H41,H42,H43,H44,H45, I41,I42,I43,I44,I45,J41,J42,J43,J44,J45]),nl, write_line([F51,F52,F53,F54,F55,G51,G52,G53,G54,G55,H51,H52,H53,H54,H55, I51,I52,I53,I54,I55,J51,J52,J53,J54,J55]),nl, write_line([K11,K12,K13,K14,K15,L11,L12,L13,L14,L15,M11,M12,M13,M14,M15, N11,N12,N13,N14,N15,O11,O12,O13,O14,O15]),nl, write_line([K21,K22,K23,K24,K25,L21,L22,L23,L24,L25,M21,M22,M23,M24,M25, N21,N22,N23,N24,N25,O21,O22,O23,O24,O25]),nl, write_line([K31,K32,K33,K34,K35,L31,L32,L33,L34,L35,M31,M32,M33,M34,M35, N31,N32,N33,N34,N35,O31,O32,O33,O34,O35]),nl, write_line([K41,K42,K43,K44,K45,L41,L42,L43,L44,L45,M41,M42,M43,M44,M45, N41,N42,N43,N44,N45,O41,O42,O43,O44,O45]),nl, write_line([K51,K52,K53,K54,K55,L51,L52,L53,L54,L55,M51,M52,M53,M54,M55, N51,N52,N53,N54,N55,O51,O52,O53,O54,O55]),nl, write_line([P11,P12,P13,P14,P15,Q11,Q12,Q13,Q14,Q15,R11,R12,R13,R14,R15, S11,S12,S13,S14,S15,T11,T12,T13,T14,T15]),nl, write_line([P21,P22,P23,P24,P25,Q21,Q22,Q23,Q24,Q25,R21,R22,R23,R24,R25, S21,S22,S23,S24,S25,T21,T22,T23,T24,T25]),nl, write_line([P31,P32,P33,P34,P35,Q31,Q32,Q33,Q34,Q35,R31,R32,R33,R34,R35, S31,S32,S33,S34,S35,T31,T32,T33,T34,T35]),nl, write_line([P41,P42,P43,P44,P45,Q41,Q42,Q43,Q44,Q45,R41,R42,R43,R44,R45, S41,S42,S43,S44,S45,T41,T42,T43,T44,T45]),nl, write_line([P51,P52,P53,P54,P55,Q51,Q52,Q53,Q54,Q55,R51,R52,R53,R54,R55, S51,S52,S53,S54,S55,T51,T52,T53,T54,T55]),nl, write_line([U11,U12,U13,U14,U15,V11,V12,V13,V14,V15,W11,W12,W13,W14,W15, X11,X12,X13,X14,X15,Y11,Y12,Y13,Y14,Y15]),nl, write_line([U21,U22,U23,U24,U25,V21,V22,V23,V24,V25,W21,W22,W23,W24,W25, X21,X22,X23,X24,X25,Y21,Y22,Y23,Y24,Y25]),nl, write_line([U31,U32,U33,U34,U35,V31,V32,V33,V34,V35,W31,W32,W33,W34,W35, X31,X32,X33,X34,X35,Y31,Y32,Y33,Y34,Y35]),nl, write_line([U41,U42,U43,U44,U45,V41,V42,V43,V44,V45,W41,W42,W43,W44,W45, X41,X42,X43,X44,X45,Y41,Y42,Y43,Y44,Y45]),nl, write_line([U51,U52,U53,U54,U55,V51,V52,V53,V54,V55,W51,W52,W53,W54,W55, X51,X52,X53,X54,X55,Y51,Y52,Y53,Y54,Y55]),nl. write_line([]). write_line([X|Xs]):- int_to_letter(X,Y), write(Y), write_line(Xs). % read in the initial board and generate constraints read_board(F):- see(F), read_5_lines('A'), read_5_lines('F'), read_5_lines('K'), read_5_lines('P'), read_5_lines('U'), seen. read_5_lines(A):- read_line(A,1,1), read_line(A,2,1), read_line(A,3,1), read_line(A,4,1), read_line(A,5,1). read_line(A,I,J):- get0(X), read_line_rest(A,I,J,X). read_line_rest(A,I,J,X):- X=:=10,!. % newline read_line_rest(A,I,J,X):- J=:=6,!, next_letter(A,B), read_line_rest(B,I,1,X). read_line_rest(A,I,J,X):- X=:=32,!, J1 is J+1, get0(X1), read_line_rest(A,I,J1,X1). read_line_rest(A,I,J,X):- build_var_name(A,I,J,Var), letter_to_int(X,Int), write(Var#=Int),write(','), J1 is J+1, get0(X1), read_line_rest(A,I,J1,X1). build_var_name(A,I,J,Var):- name(A,[Ai]), name(I,[Ii]), name(J,[Ji]), name(Var,[Ai,Ii,Ji]). letter_to_int(X,Int):- X>=0'0,X=<0'9,!, Int is X-0'0. letter_to_int(X,Int):- X>=0'A,X=<0'Z,!, Int is X-0'A+10. letter_to_int(X,Int):- write('wrong letter'),nl. int_to_letter(X,L):- X>=0,X=<9,!, L = X. int_to_letter(X,L):- X>=10,X=<25,!, Li is X-10+0'A, name(L,[Li]). int_to_letter(X,L):- write('wrong int'),nl. next_letter(A,B):- name(A,[Ai]), Bi is Ai+1, name(B,[Bi]). reverse(X,Y):- reverse1(X,[],Y). reverse1([],L0,L):- L=L0. reverse1([X|Xs],L0,L):- reverse1(Xs,[X|L0],L).