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/dcg/number_3/common.py | 30 ++++++++++++++++++++++++++++++ prolog/problems/dcg/number_3/en.py | 13 +++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 prolog/problems/dcg/number_3/common.py create mode 100644 prolog/problems/dcg/number_3/en.py (limited to 'prolog/problems/dcg/number_3') diff --git a/prolog/problems/dcg/number_3/common.py b/prolog/problems/dcg/number_3/common.py new file mode 100644 index 0000000..cc4bde7 --- /dev/null +++ b/prolog/problems/dcg/number_3/common.py @@ -0,0 +1,30 @@ +id = 167 +group = 'dcg' +number = 74 +visible = True +facts = None + +solution = '''\ +number(Num) --> dig167(N), { l2n167(N,Num) }. +number(Num) --> nonzero167([N]), numb_next167(N1), { l2n167([N|N1],Num) }. + +zero167([0]) --> [0]. +nonzero167([N]) --> [N], {memb167(N, [1,2,3,4,5,6,7,8,9])}. + +dig167(N) --> zero167(N). +dig167(N) --> nonzero167(N). +numb_next167(N) --> dig167(N). +numb_next167([N|N1]) --> dig167([N]), numb_next167(N1). + +memb167(X, [X|_]). +memb167(X, [_|T]) :- + memb167(X, T). + +l2n167(L, N) :- + l2n167(L, 0, N). +l2n167([N], S, R) :- + R is S*10+N. +l2n167([H|T], S, N) :- + S1 is S*10+H, + l2n167(T, S1, N). +''' diff --git a/prolog/problems/dcg/number_3/en.py b/prolog/problems/dcg/number_3/en.py new file mode 100644 index 0000000..a7a22fa --- /dev/null +++ b/prolog/problems/dcg/number_3/en.py @@ -0,0 +1,13 @@ +id = 167 +name = 'number/3' +slug = 'numbers with meaning' + +description = '''\ +

Write a DCG with the starting symbol number for the language of non-negative integers. The numbers may contain leading zeros. The meaning of a word in this language is the numeric value of the represented number.

+
+  ?- number(N, [1,2,3,4], []).
+    N = 1234.
+
+''' + +hint = {} -- cgit v1.2.1