summaryrefslogtreecommitdiff
path: root/prolog/problems/license_plates/genexp_2/common.py
blob: ecdc7727bcf2a994aaed835836f5bc27719c6e12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# coding=utf-8

id = 146
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).
'''