daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Dec 10th, 2018 168 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. % Author:
  2. % Date: 10/15/2018
  3.     barbat(andrei).
  4.     barbat(cristi).
  5.     barbat(marius).
  6.     barbat(ovidiu).
  7.     barbat(george).
  8.     barbat(constantin).
  9.     barbat(adrian).
  10.     barbat(costin).
  11.     femeie(elena).
  12.     femeie(ana).
  13.     femeie(adriana).
  14.     femeie(andreea).
  15.     femeie(georgeta).
  16.     femeie(larisa).
  17.     femeie(maria).
  18.     femeie(cristina).
  19.     parinte(andrei, cristi).
  20.     parinte(andrei, elena).
  21.     parinte(cristi, adriana).
  22.     parinte(cristi, marius).
  23.     parinte(cristi, ovidiu).
  24.     parinte(elena, ana).
  25.     parinte(ana, george).
  26.     cuplu(andreea, andrei).
  27.     cuplu(cristina, cristi).
  28.     cuplu(larisa, ovidiu).
  29.     cuplu(maria, marius).
  30.     cuplu(adriana, adrian).
  31.     cuplu(elena, constantin).
  32.     cuplu(ana, costin).
  33.     cuplu(georgeta, george).
  34.     frate(X,Y):-parinte(Z,X),parinte(Z,Y),X\=Y,barbat(Y).
  35.     sora(X,Y):-parinte(Z,X),parinte(Z,Y),X\=Y,femeie(Y).
  36.     fiu(X,Y):-parinte(Y,X), barbat(Y).
  37.     fiu(X,Y):-parinte(Y,X), femeie(Y).
  38.     soacra(X,Y):-cuplu(X,Z),parinte(Y,Z), femeie(Y).
  39.     soacra(X,Y):-cuplu(Z,X),parinte(Y,Z), femeie(Y).
  40.     soacra(X,Y):-cuplu(X,Z),parinte(A,Z), cuplu(Y,A), femeie(Y).
  41.     soacra(X,Y):-cuplu(Z,X),parinte(A,Z), cuplu(Y,A), femeie(Y).
  42.     cumnatM(X,Y):-cuplu(X,Z),frate(Z,Y).
  43.     cumnatM(X,Y):-cuplu(Z,X),frate(Z,Y).
  44.     cumnata(X,Y):-cuplu(X,Z),sora(Z,Y).
  45.     cumnata(X,Y):-cuplu(Z,X),sora(Z,Y).
  46.     ginere(X,Y):-parinte(X,Z),cuplu(Z,Y),barbat(Y).
  47.     ginere(X,Y):-parinte(X,Z),cuplu(Y,Z),barbat(Y).
  48.     ginere(X,Y):-cuplu(X,Z), parinte(Z,A),cuplu(A,Y),barbat(Y).
  49.     ginere(X,Y):-cuplu(Z,X), parinte(Z,A),cuplu(A,Y),barbat(Y).
  50.     cumnat(X,Y):-cuplu(X,Z),parinte(A,Z),parinte(A,Y),Z\=Y.
  51.     cumnat(X,Y):-cuplu(X,Z),parinte(A,Z),parinte(A,B),cuplu(B,Y),B\=Y,X\=Y.
  52.     cumnat(X,Y):-cuplu(X,Z),parinte(A,Z),parinte(A,B),cuplu(Y,B),B\=Y,X\=Y.
  53.     cumnat(X,Y):-cuplu(Z,X),parinte(A,Z),parinte(A,B),cuplu(B,Y),B\=Y,X\=Y.
  54.     cumnat(X,Y):-cuplu(Z,X),parinte(A,Z),parinte(A,B),cuplu(Y,B),B\=Y,X\=Y.
  55.     copii(X):-parinte(X,Y),writeln(Y),fail.
  56.     copii(_X).
  57.     nepoti(X):-parinte(X,Z),parinte(Z,Y),writeln(Y),fail.
  58.     nepoti(_X).
  59.     descendenti(X):-copii(X),nepoti(X).
  60.     usa(afara,hol).
  61.     usa(hol,afara).
  62.     usa(hol,birou).
  63.     usa(birou,hol).
  64.     usa(birou,bucatarie).
  65.     usa(bucatarie,birou).
  66.     usa(sufragerie,bucatarie).
  67.     usa(bucatarie,sufragerie).
  68.     usa(subsol,bucatarie).
  69.     usa(bucatarie,subsol).
  70.     aici(bucatarie).
  71.     obiecte(hol,cuier).
  72.     obiecte(birou,masa).
  73.     obiecte(birou,calculator).
  74.     obiecte(birou,scaun).
  75.     obiecte(sufragerie,televizor).
  76.     obiecte(sufragerie,biblioteca).
  77.     obiecte(sufragerie,fotolii).
  78.     obiecte(sufragerie,canapea).
  79.     obiecte(bucatarie,aragaz).
  80.     obiecte(bucatarie,frigider).
  81.     obiecte(bucatarie,masa).
  82.     obiecte(bucatarie,scaune).
  83.     obiecte(bucatarie,biscuiti).
  84.     obiecte(bucatarie,mere).
  85.     obiecte(subsol,masina_de_spalat).
  86.     obiecte(subsol,rufe_murdare).
  87.     ob(X):-obiecte(X,Y),writeln(Y),fail.
  88.     ob(_X).
  89.     camere(X):-usa(X,Y),writeln(Y),fail.
  90.     camere(_X).
  91.     start(X):-write('Esti in '),write(X),
  92.     write('Poti vedea '),ob(X),
  93.     write('Poti merge in' ),camere(X).
  94.     suma(X,Y,S):-S is X+Y.
  95.     numar(3).
  96.     numar(4).
  97.     numar(5).
  98.     unitate(X,Z):-Z is X+1.
  99.     patrat(X,Z):-Z is X*X.
  100.     maxim2(X,Y,Z):-X>Y,Z is X.
  101.     maxim2(X,Y,Z):-X<Y,Z is Y.
  102.     maxim2(X,Y,Z):-X=Y,Z is Y.
  103.     maxim3(X,Y,A,Z):-Y>X,Y>A,Z is Y.
  104.     maxim3(X,Y,A,Z):-X>Y,X>A,Z is X.
  105.     maxim3(X,Y,A,Z):-A>Y,A>X,Z is A.
  106.     maxim3(X,Y,A,Z):-A=Y,A=X,X=Y,Z is A.
  107.     modul(X,Z):-X>0,Z is X.
  108.     modul(X,Z):-X<0,Z is -X.
  109.     modul(X,Z):-X=0,Z is X.
  110.     paritate(X):-Y is X mod 2, Y=1, write('Impar').
  111.     paritate(X):-Y is X mod 2, Y=0, write('Par').
  112.     par(X,0):-0 is X mod 2.
  113.     impar(X,1):-1 is X mod 2.
  114.     semn(X):-X>=0, write('Pozitiv').
  115.     semn(X):-X<0, write('Negativ').
  116.     f1(X,Z):-Z is 3*X*X-4.
  117.     f2(X,Z):-Z is 4*X*X+2*X-3.
  118.     f3(X,Z):-X>0,Z is X-1.
  119.     f3(X,Z):-X=<0,Z is 0.
  120.     f4(X,Z):-modul(X,Y),Z is Y-4.
  121.     f5(X,Z):-Y is X-3, modul(Y,A), Z is 2*A.
  122.     f6(X,Z):-X>10, Z is X*X+1.
  123.     f6(X,Z):-X=<10, modul(X,Y), Z is Y-4.
  124.     f7(X,Z):-par(X,0),Z is 2*X*X+1.
  125.     f7(X,Z):-impar(X,1),Z is X-7.
  126.     nota(ion,4).
  127.     nota(marius,8).
  128.     nota(adriana,3).
  129.     nota(carmen,10).
  130.     promovat(X):-nota(X,Y),Y>=5, write('Promovat').
  131.     promovat(X):-nota(X,Y),Y<5, write('Picat').
  132.     ecgrad1(A,B,Z):-A=0, write('Nu poate fi rezolvata ').
  133.     ecgrad1(A,B,Z):-A\=0, Z is (0-B)/A.
  134.     ecgrad2(A,B,C,Z):-A=0,ecgrad1(B,C,Z).
  135.     ecgrad2(A,B,C,Z):-D is B*B-4*A*C, D<0, write('Nu poate fi rezolvata, radacini complexe').
  136.     ecgrad2(A,B,C,Z):-D is B*B-4*A*C, D=0, Z is -B/(2*A).
  137.     ecgrad2(A,B,C,Z):-D is B*B-4*A*C, D>0, X is (-B-sqrt(D))/(2*A), write(X), writeln(' '), Z is (-B+sqrt(D))/(2*A).
  138.     discuta(A,B):-cunoaste(A,B).
  139.     discuta(X,Y):-cunoaste(X,Z),discuta(Z,Y).
  140.     cunoaste(maria,ana).
  141.     cunoaste(ana,mircea).
  142.     cunoaste(mircea,mihai).
  143.     fact(1,1).
  144.     fact(N,F):-N1 is N-1, fact(N1,F1),F is F1*N.
  145.     fact2(1,T,F):-T=F.
  146.     fact2(N,T,F):-N1 is N-1,T1 is T*N,fact2(N1,T1,F).
  147.     suma(1,1).
  148.     suma(N,S):-N1 is N-1, suma(N1,S1),S is N+S1.
  149.     suma2(1,1).
  150.     suma2(N,S):-N1 is N-1, suma2(N1,S1),S is 1/N+S1.
  151.     fibo(1,1).
  152.     fibo(2,1).
  153.     fibo(N,R):-N1 is N-1, N2 is N-2, fibo(N1,R1), fibo(N2,R2), R is R1+R2.
  154.     ac(1,N,R):-R is N+1.
  155.     ac(M,0,R):-M1 is M-1, ac(M1,1,R).
  156.     ac(M,N,R):-M1 is M-1,N1 is N-1, ac(M,N1,R1),ac(M1,R1,R).
  157.     cmmdc(A,A,D):-D is A.
  158.     cmmdc(A,B,D):-A<B,A\=B,B1 is B-A, cmmdc(A,B1,D).
  159.     cmmdc(A,B,D):-A>B,A\=B,A1 is A-B, cmmdc(A1,B,D).
  160.     putere(N,0,1).
  161.     putere(N,M,R):-M1 is M-1,putere(N,M1,R1),R is R1*N.
  162.     toatenr(0).
  163.     toatenr(N):-N1 is N-1,toatenr(N1),write(N),nl.
  164.     nrpare(0):-write('0').
  165.     nrpare(N):-V is N mod 2, N1 is N-1, V\=1,write(N),nl,nrpare(N1).
  166.     nrpare(N):-V is N mod 2, N1 is N-1, V\=0,nrpare(N1).
  167.     divizor(K,N):-V is N mod K, V=0.
  168.     divizor2(K,N):-V is N mod K, V=0,write(K),nl.
  169.     divizor2(K,N):-V is N mod K, V\=0.
  170.     divizori(N,N).
  171.     divizori(N,D):-D<N, D1 is D+1,divizor2(D,N),divizori(N,D1).
  172.     afis([]).
  173.     afis([X|R]):-write(X),tab(1),afis(R).
  174.     nr([],0).
  175.     nr([X|R],N):-nr(R,N1),N is N1+1.
  176.     apart(X,[X|R]).
  177.     apart(X,[Y|R]):-apart(X,R).
  178.     ultim(X,[X|[]]).
  179.     ultim(X,[Y|R]):-ultim(X,R).
  180.     sumalista([],0).
  181.     sumalista([Y|R],X):-sumalista(R,X1),X is Y+X1.
  182.     sumalistapoz([],0).
  183.     sumalistapoz([Y|R],X):-Y>0,sumalistapoz(R,X1),X is Y+X1.
  184.     sumalistapoz([Y|R],X):-Y<0,sumalistapoz(R,X).
  185.     media([Y|R],X):-sumalista([Y|R],X1),nr([Y|R],N),X is X1/N.
  186.     maximlista([X],X).
  187.     maximlista([Y|R],M):-maximlista(R,X1),Y>X1,M is Y.
  188.     maximlista([Y|R],M):-maximlista(R,X1),Y<X1,M is X1.
  189.     copie([X|R],L):-copie(R,R1),L=[X|R1].
  190.     eliminare([],X,[]).
  191.     eliminare([X|R],X,R1):-eliminare(R,X,R1).
  192.     eliminare([M|R],X,[M|R1]):-eliminare(R,X,R1).
  193.     listapare([],[]).
  194.     listapare([M|R],R1):-N is M mod 2,N\=0,listapare(R,R1).
  195.     listapare([M|R],[M|R1]):-N is M mod 2,N=0,listapare(R,R1).
  196.     pozpare([],[]).
  197.     pozpare([X],[]).
  198.     pozpare([X,Y|L],[Y|R]):-pozpare(L,R).
  199.     maximl2([],Mt,M):-M=Mt.
  200.     maximl2([X|R],Mt,M):-X>Mt,maximl2(R,X,M).
  201.     maximl2([X|R],Mt,M):-X=<Mt,maximl2(R,Mt,M).
  202.     maximl([X|R],M):-maximl2(R,X,M).
  203.    
  204.     pozmaximl2([],Mt,M,N,Poz,P):-M=Mt,P=Poz.
  205.     pozmaximl2([X|R],Mt,M,N,Poz,P):-X=<Mt,N1 is N+1,pozmaximl2(R,Mt,M,N1,Poz,P).
  206.     pozmaximl2([X|R],Mt,M,N,Poz,P):-X>Mt,Poz1 is N,N1 is N+1,pozmaximl2(R,X,M,N1,Poz1,P).
  207.     pozmaximl([X|R],M,P):-pozmaximl2(R,X,M,2,1,P).
  208.     prefix([],L).
  209.     prefix([X|R1],[X|R2]):-prefix(R1,R2).
  210.     sufix(L,L).
  211.     sufix(L,[X|R]):-sufix(L,R).
  212.     sublista(L1,L):-prefix(L2,L),sufix(L1,L2).
  213.     comparatieliste([],[]):-write('Liste au numar egal de elemente').
  214.     comparatieliste(X,[]):-write('Prima lista are mai multe elemente').
  215.     comparatieliste([],X):-write('A doua lista are mai multe elemente').
  216.     comparatieliste([X|R1],[Y|R2]):-comparatieliste(R1,R2).
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top