From 95e2fe57f6e4639f6ae9f1fef368829d5090dbf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Smodi=C5=A1?= Date: Tue, 18 Aug 2015 16:06:19 +0200 Subject: Exported all problems from the SQLite database into the new directory structure. --- prolog/problems/trees/memberbt_2/common.py | 13 +++++++++++++ prolog/problems/trees/memberbt_2/en.py | 14 ++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 prolog/problems/trees/memberbt_2/common.py create mode 100644 prolog/problems/trees/memberbt_2/en.py (limited to 'prolog/problems/trees/memberbt_2') diff --git a/prolog/problems/trees/memberbt_2/common.py b/prolog/problems/trees/memberbt_2/common.py new file mode 100644 index 0000000..f0ae0bd --- /dev/null +++ b/prolog/problems/trees/memberbt_2/common.py @@ -0,0 +1,13 @@ +id = 135 +group = 'trees' +number = 42 +visible = True +facts = None + +solution = '''\ +memberBT(X, b(_, X, _)). +memberBT(X, b(L, _, _)) :- + memberBT(X, L). +memberBT(X, b(_, _, R)) :- + memberBT(X, R). +''' diff --git a/prolog/problems/trees/memberbt_2/en.py b/prolog/problems/trees/memberbt_2/en.py new file mode 100644 index 0000000..fcca1d9 --- /dev/null +++ b/prolog/problems/trees/memberbt_2/en.py @@ -0,0 +1,14 @@ +id = 135 +name = 'memberBT/2' +slug = 'find elements in a binary tree' + +description = '''\ +

memberBT(X, T): X is an element of the binary tree T. A binary tree node is represented with the structure b(L, E, R), where L and R are left and right subtrees, respectively, and E is the node's value. An empty tree is denoted by nil.

+
+  ?- memberBT(X, b(b(nil,2,nil),1,b(nil,3,nil))).
+    X = 1 ;
+    X = 2 ;
+    X = 3.
+
''' + +hint = {} -- cgit v1.2.1