summaryrefslogtreecommitdiff
path: root/prolog/problems/license_plates/genexp_2/common.py
blob: a91c39299e2219b71bdbcc55172e845637c0caa8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
id = 146
group = 'license_plates'
number = 53
visible = True
facts = None

solution = '''\
memb146(X, [X|_]).
memb146(X, [_|T]) :-
  memb146(X, T).

conc146([], L, L).
conc146([H|T], L2, [H|L]) :-
  conc146(T, L2, L).

genexp([Exp], Exp).
genexp(L, Exp) :-
  conc146(Before, [N1,N2|After], L),
  memb146(Op, ['+','-','*','/']),
  NExp =.. [Op, N1, N2],
  conc146(Before, [NExp|After], L1),
  genexp(L1, Exp).
'''