diff options
| -rw-r--r-- | challenge-191/adam-russell/prolog/ch-2.p | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/challenge-191/adam-russell/prolog/ch-2.p b/challenge-191/adam-russell/prolog/ch-2.p index 6711b4d1ff..83b7f8518d 100644 --- a/challenge-191/adam-russell/prolog/ch-2.p +++ b/challenge-191/adam-russell/prolog/ch-2.p @@ -1,11 +1,14 @@ cute(_, _) --> []. cute(N, CuteList) --> [X], {between(1, N, X), \+ member(X, CuteList), - append(CuteList, [X], CuteListUpdated), - nth(I, CuteListUpdated, X), - 0 is mod(X, I)}, + length(CuteList, CuteListLength), + succ(CuteListLength, I), + (0 is mod(X, I); 0 is mod(I, X)), + append(CuteList, [X], CuteListUpdated)}, cute(N, CuteListUpdated). -cute(N, CuteList) --> [X], {between(1, N, X), \+ member(X, CuteList), - append(CuteList, [X], CuteListUpdated), - nth(I, CuteListUpdated, X), - 0 is mod(I, X)}, - cute(N, CuteListUpdated).
\ No newline at end of file + +main:- + N = 15, + findall(Cute, (length(Cute, N), phrase(cute(N, []), Cute)), C), + sort(C, CuteList), + length(CuteList, NumberCuteList), + write(NumberCuteList), nl.
\ No newline at end of file |
