Skip to content

Instantly share code, notes, and snippets.

@ejrh
Created December 14, 2014 03:40
Show Gist options
  • Save ejrh/d0672ebf605140ec7257 to your computer and use it in GitHub Desktop.
Save ejrh/d0672ebf605140ec7257 to your computer and use it in GitHub Desktop.
step(0, []).
step(1,[1]).
step(2,[2]).
step(3,[3]).
step(N,[H|T]) :-
N > 0,
member(H, [1,2,3]),
Remaining is N - H,
Remaining > 0,
step(Remaining, T).
count_steps(N, S) :-
bagof(X, step(N, X), B),
length(B, S).
print_table(Max) :-
findall(_,(
between(0, Max, N),
count_steps(N, S),
write((N,S)), nl
),_).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment