diff options
Diffstat (limited to 'prolog/problems/dcg/paren_3')
-rw-r--r-- | prolog/problems/dcg/paren_3/common.py | 10 | ||||
-rw-r--r-- | prolog/problems/dcg/paren_3/en.py | 13 |
2 files changed, 23 insertions, 0 deletions
diff --git a/prolog/problems/dcg/paren_3/common.py b/prolog/problems/dcg/paren_3/common.py new file mode 100644 index 0000000..cf7c439 --- /dev/null +++ b/prolog/problems/dcg/paren_3/common.py @@ -0,0 +1,10 @@ +id = 169 +group = 'dcg' +number = 76 +visible = True +facts = None + +solution = '''\ +paren(0) --> []. +paren(D) --> ['('], paren(D1), [')'], paren(D2), { D1 >= D2, D is D1 + 1 ; D1 < D2 , D is D2 }. +''' diff --git a/prolog/problems/dcg/paren_3/en.py b/prolog/problems/dcg/paren_3/en.py new file mode 100644 index 0000000..f4d4c3b --- /dev/null +++ b/prolog/problems/dcg/paren_3/en.py @@ -0,0 +1,13 @@ +id = 169 +name = 'paren/3' +slug = 'properly nested parens with meaning' + +description = '''\ +<p>Write a DCG with the starting symbol <code>paren</code> for the language of properly nested sequences of parentheses. The meaning of a word in this language is the maximum depth of the nested parentheses.</p> +<pre> + ?- paren(D, ['(','(',')',')','(',')'], []). % (())() + D = 2. +</pre> +''' + +hint = {} |