:-use_module(library(lists)). test(W1,W2,K,ADD):- sub_atom(W1, ADD, XL, 0, S), sub_atom(W2, 0, XL, _, S), XL =< K, XL > 0. szolancfa(K, [W1|L], csucs(W1,RL)):- findall(P, (select(W2,L,L2), test(W1,W2,K,_), szolancfa(K, [W2|L2], P)), RL).