blob: 9b25f12d1a40defd61457b6d01802e5e3f62f71a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# coding=utf-8
name = 'genexp/2'
slug = 'generate an arithmetic expression from a list'
description = '''\
<p><code>genexp(L, E)</code>: the expression <code>E</code> is obtained from the list <code>L</code> by inserting arithmetic operators between list elements. Your code should generate all valid solutions.</p>
<pre>
?- genexp([1,2,3], L).
L = 1+2+3 ;
L = 1+2-3 ;
L = (1+2)*3 ;
L = (1+2)/3 ;
L = 1-2+3 ;
L = 1-2-3 ;
…
</pre>'''
hint = {}
|