-
Notifications
You must be signed in to change notification settings - Fork 17
/
cross_words01.pi
50 lines (38 loc) · 1.47 KB
/
cross_words01.pi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
%%import cp.
%%% ALTERNATIVA COM CP
%% by CCS
main => imp_cross.
%%% Aqui as palavras - dicionario -- Vem do problema
index(-,-,-,-,-,-,-,-)
word(abalone , a,b,a,l,o,n,e) .
word(abandon , a,b,a,n,d,o,n) .
word(enhance , e,n,h,a,n,c,e) .
word(anagram , a,n,a,g,r,a,m) .
word(connect , c,o,n,n,e,c,t) .
word(elegant , e,l,e,g,a,n,t) .
/*** ainda INEFICIENTE .... */
%%%%%%%%%%% MODELAGEM DO PROBLEMA
cross(L) =>
L = [PH1, PH2, PH3, PV1, PV2, PV3 ],
/* Declarando dominbios e variaveis */
word(PH1, _, H12 , _ , H14, _ , H16, _),
word(PH2, _, H22 , _ , H24, _ , H26, _),
word(PH3, _, H32 , _ , H34, _ , H36, _),
word(PV1, _, V12 , _ , V14, _ , V16, _),
word(PV2, _, V22 , _ , V24, _ , V26, _),
word(PV3, _, V32 , _ , V34, _ , V36, _),
/* Restricoes e contorno do problema */
H12 == V12, H14 == V22, H16 == V32,
H22 == V14, H24 == V24, H26 == V34,
H32 == V16, H34 == V26, H36 == V36.
%%%%%%%%%%%%%%%%%%% IMPRESSAO
imp_cross ?=>
cross([PH1, PH2, PH3, PV1, PV2, PV3 ]) ,
nl, write(' HORIZONTAIS: '), write(PH1), write(' '),
write(PH2), write(' '), write(PH3),
nl, write(' VERTICAIS: '), write(PV1), write(' '),
write(PV2), write(' '), write(PV3),
fail.
imp_cross => printf("\n***********************************************\n"),
true .
/************************************************************************/