summaryrefslogtreecommitdiff
path: root/prolog/problems/trees
diff options
context:
space:
mode:
Diffstat (limited to 'prolog/problems/trees')
-rw-r--r--prolog/problems/trees/deletebt_3/en.py8
-rw-r--r--prolog/problems/trees/depthbt_2/en.py4
-rw-r--r--prolog/problems/trees/insertbt_3/en.py10
-rw-r--r--prolog/problems/trees/maxt_2/en.py4
-rw-r--r--prolog/problems/trees/memberbt_2/en.py8
-rw-r--r--prolog/problems/trees/membert_2/en.py8
-rw-r--r--prolog/problems/trees/mirrorbt_2/en.py4
-rw-r--r--prolog/problems/trees/numberbt_2/en.py4
-rw-r--r--prolog/problems/trees/tolistbt_2/en.py4
9 files changed, 27 insertions, 27 deletions
diff --git a/prolog/problems/trees/deletebt_3/en.py b/prolog/problems/trees/deletebt_3/en.py
index 215fced..eedab0a 100644
--- a/prolog/problems/trees/deletebt_3/en.py
+++ b/prolog/problems/trees/deletebt_3/en.py
@@ -6,10 +6,10 @@ slug = 'delete an element from a binary tree'
description = '''\
<p><code>deleteBT(X, T, NewT)</code>: the binary tree <code>NewT</code> is obtained from <code>T</code> by deleting one occurence of the element <code>X</code>. If <code>X</code> is not a leaf node, the root of one of its subtrees is moved up. Your code should generate all valid solutions.</p>
<pre>
- ?- deleteBT(1, b(b(b(nil,4,nil),2,b(nil,6,nil)),1,b(nil,3,b(nil,5,nil))), T).
- T = b(b(nil,4,b(nil,6,nil)),2,b(nil,3,b(nil,5,nil))) ;
- T = b(b(b(nil,4,nil),6,nil),2,b(nil,3,b(nil,5,nil))) ;
- T = b(b(b(nil,4,nil),2,b(nil,6,nil)),3,b(nil,5,nil)).
+?- deleteBT(1, b(b(b(nil,4,nil),2,b(nil,6,nil)),1,b(nil,3,b(nil,5,nil))), T).
+ T = b(b(nil,4,b(nil,6,nil)),2,b(nil,3,b(nil,5,nil))) ;
+ T = b(b(b(nil,4,nil),6,nil),2,b(nil,3,b(nil,5,nil))) ;
+ T = b(b(b(nil,4,nil),2,b(nil,6,nil)),3,b(nil,5,nil)).
</pre>'''
hint = {}
diff --git a/prolog/problems/trees/depthbt_2/en.py b/prolog/problems/trees/depthbt_2/en.py
index 94fec48..c3f7d4c 100644
--- a/prolog/problems/trees/depthbt_2/en.py
+++ b/prolog/problems/trees/depthbt_2/en.py
@@ -6,8 +6,8 @@ slug = 'find the depth of a binary tree'
description = '''\
<p><code>depthBT(T, D)</code>: <code>D</code> is the depth of the binary tree <code>T</code>.</p>
<pre>
- ?- depthBT(b(b(b(nil,4,nil),2,b(nil,6,nil)),1,nil), D).
- D = 3.
+?- depthBT(b(b(b(nil,4,nil),2,b(nil,6,nil)),1,nil), D).
+ D = 3.
</pre>'''
hint = {}
diff --git a/prolog/problems/trees/insertbt_3/en.py b/prolog/problems/trees/insertbt_3/en.py
index 08eb2cd..c0fa47c 100644
--- a/prolog/problems/trees/insertbt_3/en.py
+++ b/prolog/problems/trees/insertbt_3/en.py
@@ -6,11 +6,11 @@ slug = 'insert an element into a binary tree'
description = '''\
<p><code>insertBT(X, T, NewT)</code>: the binary tree <code>NewT</code> is obtained from <code>T</code> by inserting the element <code>X</code> at a certain position. This is the opposite of the predicate <code>deleteBT/3</code>. Your code should generate all valid solutions.</p>
<pre>
- ?- insertBT(2, b(nil,1,nil), T).
- T = b(b(nil,1,nil),2,nil) ;
- T = b(nil,2,b(nil,1,nil)) ;
- T = b(b(nil,2,nil),1,nil) ;
- T = b(nil,1,b(nil,2,nil)).
+?- insertBT(2, b(nil,1,nil), T).
+ T = b(b(nil,1,nil),2,nil) ;
+ T = b(nil,2,b(nil,1,nil)) ;
+ T = b(b(nil,2,nil),1,nil) ;
+ T = b(nil,1,b(nil,2,nil)).
</pre>'''
hint = {}
diff --git a/prolog/problems/trees/maxt_2/en.py b/prolog/problems/trees/maxt_2/en.py
index 20db52e..bb222f8 100644
--- a/prolog/problems/trees/maxt_2/en.py
+++ b/prolog/problems/trees/maxt_2/en.py
@@ -6,8 +6,8 @@ slug = 'find the greatest element in a tree'
description = '''\
<p><code>maxT(Tree, Max)</code>: <code>Max</code> is the greatest element in the tree <code>Tree</code>.</p>
<pre>
- ?- maxT(t(1, t(2), t(3)), Max).
- Max = 3.
+?- maxT(t(1, t(2), t(3)), Max).
+ Max = 3.
</pre>'''
hint = {}
diff --git a/prolog/problems/trees/memberbt_2/en.py b/prolog/problems/trees/memberbt_2/en.py
index e8d48f2..1559151 100644
--- a/prolog/problems/trees/memberbt_2/en.py
+++ b/prolog/problems/trees/memberbt_2/en.py
@@ -6,10 +6,10 @@ slug = 'find elements in a binary tree'
description = '''\
<p><code>memberBT(X, T)</code>: <code>X</code> is an element of the binary tree <code>T</code>. A binary tree node is represented with the structure <code>b(L, E, R)</code>, where <code>L</code> and <code>R</code> are left and right subtrees, respectively, and <code>E</code> is the node's value. An empty tree is denoted by <code>nil</code>.</p>
<pre>
- ?- memberBT(X, b(b(nil,2,nil),1,b(nil,3,nil))).
- X = 1 ;
- X = 2 ;
- X = 3.
+?- memberBT(X, b(b(nil,2,nil),1,b(nil,3,nil))).
+ X = 1 ;
+ X = 2 ;
+ X = 3.
</pre>'''
hint = {}
diff --git a/prolog/problems/trees/membert_2/en.py b/prolog/problems/trees/membert_2/en.py
index 738d625..ef48931 100644
--- a/prolog/problems/trees/membert_2/en.py
+++ b/prolog/problems/trees/membert_2/en.py
@@ -6,10 +6,10 @@ slug = 'find elements in a tree'
description = '''\
<p><code>memberT(X, T)</code>: <code>X</code> is an element of the tree <code>T</code>. A tree node is represented with the structure <code>t(E, T1, T2...)</code>, where <code>E</code> is the node's value, followed by any number of subtrees. An empty tree is denoted by <code>nil</code>.</p>
<pre>
- ?- memberT(X, t(3, t(1), t(2))).
- X = 3 ;
- X = 1 ;
- X = 2.
+?- memberT(X, t(3, t(1), t(2))).
+ X = 3 ;
+ X = 1 ;
+ X = 2.
</pre>'''
hint = {}
diff --git a/prolog/problems/trees/mirrorbt_2/en.py b/prolog/problems/trees/mirrorbt_2/en.py
index 85c2a54..7bc622f 100644
--- a/prolog/problems/trees/mirrorbt_2/en.py
+++ b/prolog/problems/trees/mirrorbt_2/en.py
@@ -6,8 +6,8 @@ slug = 'flip a binary tree horizontally'
description = '''\
<p><code>mirrorBT(T, NewT)</code>: the binary tree <code>NewT</code> is obtained from <code>T</code> by flipping it over the vertical axis through the root node.</p>
<pre>
- ?- mirrorBT(b(b(b(nil,4,nil),2,b(nil,5,nil)),1,b(nil,3,nil)), X).
- X = b(b(nil,3,nil), 1, b(b(nil,5,nil), 2, b(nil,4,nil))).
+?- mirrorBT(b(b(b(nil,4,nil),2,b(nil,5,nil)),1,b(nil,3,nil)), X).
+ X = b(b(nil,3,nil), 1, b(b(nil,5,nil), 2, b(nil,4,nil))).
</pre>'''
hint = {}
diff --git a/prolog/problems/trees/numberbt_2/en.py b/prolog/problems/trees/numberbt_2/en.py
index 3be193d..99dc9ca 100644
--- a/prolog/problems/trees/numberbt_2/en.py
+++ b/prolog/problems/trees/numberbt_2/en.py
@@ -6,8 +6,8 @@ slug = 'find the number of nodes in a binary tree'
description = '''\
<p><code>numberBT(T, N)</code>: <code>N</code> is the number of nodes in the binary tree <code>T</code>.</p>
<pre>
- ?- numberBT(b(b(nil,2,nil),1,b(nil,3,nil)), N).
- N = 3.
+?- numberBT(b(b(nil,2,nil),1,b(nil,3,nil)), N).
+ N = 3.
</pre>'''
hint = {}
diff --git a/prolog/problems/trees/tolistbt_2/en.py b/prolog/problems/trees/tolistbt_2/en.py
index a6d0d4b..94ba3ea 100644
--- a/prolog/problems/trees/tolistbt_2/en.py
+++ b/prolog/problems/trees/tolistbt_2/en.py
@@ -6,8 +6,8 @@ slug = 'construct a list with all elements of a binary tree'
description = '''\
<p><code>tolistBT(T, L)</code>: the list <code>L</code> contains all the elements in the binary tree <code>T</code>, in infix order.</p>
<pre>
- ?- tolistBT(b(b(nil,2,nil),1,b(nil,3,nil)), L).
- L = [2,1,3].
+?- tolistBT(b(b(nil,2,nil),1,b(nil,3,nil)), L).
+ L = [2,1,3].
</pre>'''
hint = {}