Created
December 14, 2014 03:40
-
-
Save ejrh/d0672ebf605140ec7257 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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