summaryrefslogtreecommitdiff
path: root/prolog/problems/family_relations
diff options
context:
space:
mode:
authorAleš Smodiš <aless@guru.si>2015-08-18 16:06:19 +0200
committerAleš Smodiš <aless@guru.si>2015-08-18 16:06:19 +0200
commit95e2fe57f6e4639f6ae9f1fef368829d5090dbf6 (patch)
tree462ba05eb0c4732ca1c97739548801258bf47b40 /prolog/problems/family_relations
Exported all problems from the SQLite database into the new directory structure.
Diffstat (limited to 'prolog/problems/family_relations')
-rw-r--r--prolog/problems/family_relations/ancestor_2/common.py13
-rw-r--r--prolog/problems/family_relations/ancestor_2/en.py14
-rw-r--r--prolog/problems/family_relations/aunt_2/common.py17
-rw-r--r--prolog/problems/family_relations/aunt_2/en.py13
-rw-r--r--prolog/problems/family_relations/brother_2/common.py13
-rw-r--r--prolog/problems/family_relations/brother_2/en.py13
-rw-r--r--prolog/problems/family_relations/connected_3/common.py16
-rw-r--r--prolog/problems/family_relations/connected_3/en.py14
-rw-r--r--prolog/problems/family_relations/cousin_2/common.py26
-rw-r--r--prolog/problems/family_relations/cousin_2/en.py13
-rw-r--r--prolog/problems/family_relations/descendant_2/common.py13
-rw-r--r--prolog/problems/family_relations/descendant_2/en.py14
-rw-r--r--prolog/problems/family_relations/grandparent_2/common.py11
-rw-r--r--prolog/problems/family_relations/grandparent_2/en.py15
-rw-r--r--prolog/problems/family_relations/mother_2/common.py11
-rw-r--r--prolog/problems/family_relations/mother_2/en.py15
-rw-r--r--prolog/problems/family_relations/sister_2/common.py13
-rw-r--r--prolog/problems/family_relations/sister_2/en.py12
18 files changed, 256 insertions, 0 deletions
diff --git a/prolog/problems/family_relations/ancestor_2/common.py b/prolog/problems/family_relations/ancestor_2/common.py
new file mode 100644
index 0000000..61472b6
--- /dev/null
+++ b/prolog/problems/family_relations/ancestor_2/common.py
@@ -0,0 +1,13 @@
+id = 100
+group = 'family_relations'
+number = 7
+visible = True
+facts = 'family_relations'
+
+solution = '''\
+ancestor(X, Y) :-
+ parent(X, Y).
+ancestor(X, Y) :-
+ parent(X, Z),
+ ancestor(Z, Y).
+'''
diff --git a/prolog/problems/family_relations/ancestor_2/en.py b/prolog/problems/family_relations/ancestor_2/en.py
new file mode 100644
index 0000000..4853e15
--- /dev/null
+++ b/prolog/problems/family_relations/ancestor_2/en.py
@@ -0,0 +1,14 @@
+id = 100
+name = 'ancestor/2'
+slug = 'the ancestor relation'
+
+description = '''\
+<p><code>ancestor(X, Y)</code>: <code>X</code> is an ancestor (parent, grandparent,...) of <code>Y</code>.</p>
+<pre>
+ ?- ancestor(patricia, X).
+ X = john ;
+ X = michael ;
+ X = michelle.
+</pre>'''
+
+hint = {}
diff --git a/prolog/problems/family_relations/aunt_2/common.py b/prolog/problems/family_relations/aunt_2/common.py
new file mode 100644
index 0000000..78e98c5
--- /dev/null
+++ b/prolog/problems/family_relations/aunt_2/common.py
@@ -0,0 +1,17 @@
+id = 98
+group = 'family_relations'
+number = 5
+visible = True
+facts = 'family_relations'
+
+solution = '''\
+sister98(X, Y) :-
+ parent(P, X),
+ parent(P, Y),
+ female(X),
+ X \== Y.
+
+aunt(X, Y) :-
+ sister98(X, Z),
+ parent(Z, Y).
+'''
diff --git a/prolog/problems/family_relations/aunt_2/en.py b/prolog/problems/family_relations/aunt_2/en.py
new file mode 100644
index 0000000..95780a1
--- /dev/null
+++ b/prolog/problems/family_relations/aunt_2/en.py
@@ -0,0 +1,13 @@
+id = 98
+name = 'aunt/2'
+slug = 'the aunt relation'
+
+description = '''\
+<p><code>aunt(X, Y)</code>: <code>X</code> is an aunt of <code>Y</code>.</p>
+<pre>
+ ?- aunt(sally, X).
+ X = vanessa ;
+ X = patricia.
+</pre>'''
+
+hint = {}
diff --git a/prolog/problems/family_relations/brother_2/common.py b/prolog/problems/family_relations/brother_2/common.py
new file mode 100644
index 0000000..c339644
--- /dev/null
+++ b/prolog/problems/family_relations/brother_2/common.py
@@ -0,0 +1,13 @@
+id = 97
+group = 'family_relations'
+number = 4
+visible = True
+facts = 'family_relations'
+
+solution = '''\
+brother(X, Y) :-
+ parent(P, X),
+ parent(P, Y),
+ male(X),
+ X \== Y.
+'''
diff --git a/prolog/problems/family_relations/brother_2/en.py b/prolog/problems/family_relations/brother_2/en.py
new file mode 100644
index 0000000..8cae8b8
--- /dev/null
+++ b/prolog/problems/family_relations/brother_2/en.py
@@ -0,0 +1,13 @@
+id = 97
+name = 'brother/2'
+slug = 'the brother relation'
+
+description = '''\
+<p><code>brother(X, Y)</code>: <code>X</code> is a brother of <code>Y</code>.</p>
+<pre>
+ ?- brother(jeffrey, X).
+ X = william ;
+ X = sally.
+</pre>'''
+
+hint = {}
diff --git a/prolog/problems/family_relations/connected_3/common.py b/prolog/problems/family_relations/connected_3/common.py
new file mode 100644
index 0000000..9a68d36
--- /dev/null
+++ b/prolog/problems/family_relations/connected_3/common.py
@@ -0,0 +1,16 @@
+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).
+'''
diff --git a/prolog/problems/family_relations/connected_3/en.py b/prolog/problems/family_relations/connected_3/en.py
new file mode 100644
index 0000000..8fe1eed
--- /dev/null
+++ b/prolog/problems/family_relations/connected_3/en.py
@@ -0,0 +1,14 @@
+id = 102
+name = 'connected/3'
+slug = 'check if two people are connected in the family tree'
+
+description = '''\
+<p><code>connected(X, Y, N)</code>: <code>X</code> and <code>Y</code> are connected with a series of (no more than <code>N</code>) parent/child relations.</p>
+<pre>
+ ?- connected(ana, morty, 10).
+ false.
+ ?- connected(ana, margaret, 10).
+ true.
+</pre>'''
+
+hint = {}
diff --git a/prolog/problems/family_relations/cousin_2/common.py b/prolog/problems/family_relations/cousin_2/common.py
new file mode 100644
index 0000000..9285a80
--- /dev/null
+++ b/prolog/problems/family_relations/cousin_2/common.py
@@ -0,0 +1,26 @@
+id = 99
+group = 'family_relations'
+number = 6
+visible = True
+facts = 'family_relations'
+
+solution = '''\
+sister99(X, Y) :-
+ parent(P, X),
+ parent(P, Y),
+ female(X),
+ X \== Y.
+
+brother99(X, Y) :-
+ parent(P, X),
+ parent(P, Y),
+ male(X),
+ X \== Y.
+
+cousin(X, Y) :-
+ parent(PX, X),
+ parent(PY, Y),
+ ( brother99(PX, PY)
+ ;
+ sister99(PX, PY) ).
+'''
diff --git a/prolog/problems/family_relations/cousin_2/en.py b/prolog/problems/family_relations/cousin_2/en.py
new file mode 100644
index 0000000..72faa60
--- /dev/null
+++ b/prolog/problems/family_relations/cousin_2/en.py
@@ -0,0 +1,13 @@
+id = 99
+name = 'cousin/2'
+slug = 'the cousin relation'
+
+description = '''\
+<p><code>cousin(X, Y)</code>: <code>X</code> is a cousin (male or female) of <code>Y</code>.</p>
+<pre>
+ ?- cousin(andrew, X).
+ X = vanessa ;
+ X = patricia.
+</pre>'''
+
+hint = {}
diff --git a/prolog/problems/family_relations/descendant_2/common.py b/prolog/problems/family_relations/descendant_2/common.py
new file mode 100644
index 0000000..408b3c7
--- /dev/null
+++ b/prolog/problems/family_relations/descendant_2/common.py
@@ -0,0 +1,13 @@
+id = 101
+group = 'family_relations'
+number = 8
+visible = True
+facts = 'family_relations'
+
+solution = '''\
+descendant(X, Y) :-
+ parent(Y, X).
+descendant(X, Y) :-
+ parent(Y, Z),
+ descendant(X, Z).
+'''
diff --git a/prolog/problems/family_relations/descendant_2/en.py b/prolog/problems/family_relations/descendant_2/en.py
new file mode 100644
index 0000000..d4ac794
--- /dev/null
+++ b/prolog/problems/family_relations/descendant_2/en.py
@@ -0,0 +1,14 @@
+id = 101
+name = 'descendant/2'
+slug = 'the descendant relation'
+
+description = '''\
+<p><code>descendant(X, Y)</code>: <code>X</code> is a descendant (child, grandchild,...) of <code>Y</code>.</p>
+<pre>
+ ?- descendant(patricia, X).
+ X = william ;
+ X = tina ;
+ X = thomas.
+</pre>'''
+
+hint = {}
diff --git a/prolog/problems/family_relations/grandparent_2/common.py b/prolog/problems/family_relations/grandparent_2/common.py
new file mode 100644
index 0000000..12b7c0d
--- /dev/null
+++ b/prolog/problems/family_relations/grandparent_2/common.py
@@ -0,0 +1,11 @@
+id = 95
+group = 'family_relations'
+number = 2
+visible = True
+facts = 'family_relations'
+
+solution = '''\
+grandparent(X, Y) :-
+ parent(X, Z),
+ parent(Z, Y).
+'''
diff --git a/prolog/problems/family_relations/grandparent_2/en.py b/prolog/problems/family_relations/grandparent_2/en.py
new file mode 100644
index 0000000..cdc9cec
--- /dev/null
+++ b/prolog/problems/family_relations/grandparent_2/en.py
@@ -0,0 +1,15 @@
+id = 95
+name = 'grandparent/2'
+slug = 'the grandparent relation'
+
+description = '''\
+<p><code>grandparent(P, C)</code>: <code>P</code> is a grandparent of <code>C</code>.</p>
+<pre>
+ ?- grandparent(tina, X).
+ X = vanessa ;
+ X = patricia.
+ ?- grandparent(tina, vanessa).
+ true.
+</pre>'''
+
+hint = {}
diff --git a/prolog/problems/family_relations/mother_2/common.py b/prolog/problems/family_relations/mother_2/common.py
new file mode 100644
index 0000000..6c75823
--- /dev/null
+++ b/prolog/problems/family_relations/mother_2/common.py
@@ -0,0 +1,11 @@
+id = 94
+group = 'family_relations'
+number = 1
+visible = True
+facts = 'family_relations'
+
+solution = '''\
+mother(X, Y) :-
+ parent(X, Y),
+ female(X).
+'''
diff --git a/prolog/problems/family_relations/mother_2/en.py b/prolog/problems/family_relations/mother_2/en.py
new file mode 100644
index 0000000..9f1c098
--- /dev/null
+++ b/prolog/problems/family_relations/mother_2/en.py
@@ -0,0 +1,15 @@
+id = 94
+name = 'mother/2'
+slug = 'the mother-child relation'
+
+description = '''\
+<p><code>mother(M, C)</code>: <code>M</code> is the mother of <code>C</code>.</p>
+<pre>
+ ?- mother(tina, william).
+ true.
+ ?- mother(nevia, X).
+ X = luana ;
+ X = daniela.
+</pre>'''
+
+hint = {}
diff --git a/prolog/problems/family_relations/sister_2/common.py b/prolog/problems/family_relations/sister_2/common.py
new file mode 100644
index 0000000..75a2b62
--- /dev/null
+++ b/prolog/problems/family_relations/sister_2/common.py
@@ -0,0 +1,13 @@
+id = 96
+group = 'family_relations'
+number = 3
+visible = True
+facts = 'family_relations'
+
+solution = '''\
+sister(X, Y) :-
+ parent(P, X),
+ parent(P, Y),
+ female(X),
+ X \== Y.
+'''
diff --git a/prolog/problems/family_relations/sister_2/en.py b/prolog/problems/family_relations/sister_2/en.py
new file mode 100644
index 0000000..140b76f
--- /dev/null
+++ b/prolog/problems/family_relations/sister_2/en.py
@@ -0,0 +1,12 @@
+id = 96
+name = 'sister/2'
+slug = 'the sister relation'
+
+description = '''\
+<p><code>sister(X, Y)</code>: <code>X</code> is a sister of <code>Y</code>.</p>
+<pre>
+ ?- sister(vanessa, X).
+ X = patricia.
+</pre>'''
+
+hint = {}