diff options
Diffstat (limited to 'prolog/problems/license_plates/joindigits_2')
-rw-r--r-- | prolog/problems/license_plates/joindigits_2/common.py | 14 | ||||
-rw-r--r-- | prolog/problems/license_plates/joindigits_2/en.py | 15 |
2 files changed, 29 insertions, 0 deletions
diff --git a/prolog/problems/license_plates/joindigits_2/common.py b/prolog/problems/license_plates/joindigits_2/common.py new file mode 100644 index 0000000..dc3e4a5 --- /dev/null +++ b/prolog/problems/license_plates/joindigits_2/common.py @@ -0,0 +1,14 @@ +id = 145 +group = 'license_plates' +number = 52 +visible = True +facts = None + +solution = '''\ +joindigits([X], [X]). +joindigits([X,Y|T], NT) :- + XY is 10*X + Y, + joindigits([XY|T], NT). +joindigits([X,Y|T], [X|NT]) :- + joindigits([Y|T], NT). +''' diff --git a/prolog/problems/license_plates/joindigits_2/en.py b/prolog/problems/license_plates/joindigits_2/en.py new file mode 100644 index 0000000..19623d7 --- /dev/null +++ b/prolog/problems/license_plates/joindigits_2/en.py @@ -0,0 +1,15 @@ +id = 145 +name = 'joindigits/2' +slug = 'join adjacent numbers in a list' + +description = '''\ +<p><code>joindigits(L, NL)</code>: the list <code>NL</code> is obtained from <code>L</code> by arbitrarily joining neighboring digits. Your code should generate all valid solutions.</p> +<pre> + ?- joindigits([3,2,4], NL). + NL = [324] ; + NL = [32,4] ; + NL = [3,24] ; + NL = [3,2,4]. +</pre>''' + +hint = {} |