summaryrefslogtreecommitdiff
path: root/prolog/problems/clp_r/center_3
diff options
context:
space:
mode:
Diffstat (limited to 'prolog/problems/clp_r/center_3')
-rw-r--r--prolog/problems/clp_r/center_3/common.py20
-rw-r--r--prolog/problems/clp_r/center_3/en.py13
2 files changed, 33 insertions, 0 deletions
diff --git a/prolog/problems/clp_r/center_3/common.py b/prolog/problems/clp_r/center_3/common.py
new file mode 100644
index 0000000..1474ef1
--- /dev/null
+++ b/prolog/problems/clp_r/center_3/common.py
@@ -0,0 +1,20 @@
+id = 158
+group = 'clp_r'
+number = 68
+visible = True
+facts = None
+
+solution = '''\
+memb158(X, [X|_]).
+memb158(X, [_|T]) :-
+ memb158(X, T).
+
+check158([], _, _).
+check158([X/Y | T], R, Xc/Yc) :-
+ { (X-Xc)*(X-Xc) + (Y-Yc)*(Y-Yc) =< R*R },
+ check158(T, R, Xc/Yc).
+
+center(L, R, Xc/Yc) :-
+ memb158(Xc/Yc, L),
+ check158(L, R, Xc/Yc).
+'''
diff --git a/prolog/problems/clp_r/center_3/en.py b/prolog/problems/clp_r/center_3/en.py
new file mode 100644
index 0000000..b2b4c8d
--- /dev/null
+++ b/prolog/problems/clp_r/center_3/en.py
@@ -0,0 +1,13 @@
+id = 158
+name = 'center/3'
+slug = 'find central points'
+
+description = '''\
+<p><code>center(Points, R, X/Y)</code>: <code>X/Y</code> is a point in the list <code>Points</code> that is at most <code>R</code> away from all other points.</p>
+<pre>
+ ?- center([1.0/1.1, 2.0/2.1, 3.0/3.1, 4.0/4.1], 4.0, X/Y).
+ X = 2.0, Y = 2.1 ;
+ X = 3.0, Y = 3.1.
+</pre>'''
+
+hint = {}