summaryrefslogtreecommitdiff
path: root/prolog/problems/family_relations/connected_3/common.py
blob: 1221713f14b810584c0e86e11c4c38ca8567586e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# coding=utf-8

id = 102
group = 'family_relations'
number = 9
visible = True
facts = 'family_relations'

solution = '''\
connected(X, X, _).
connected(X, Y, N) :-
  N > 0,
  N1 is N - 1,
  ( parent(X, Z)
    ;
    parent(Z, X) ),
  connected(Z, Y, N1).
'''