View source with formatted comments or as raw
    1end(20).
    2stepsize(7).
    3step(N) :-
    4    end(E),
    5    bet(0,E,N).
    6bet(N, M, N) :- N =< M.
    7bet(N, M, K) :- N < M, N1 is N+1, bet(N1, M, K).
    8
    9at(0, S) :- S .=. 0.
   10
   11move(T) :- step(T), not neg_move(T).
   12neg_move(T) :- step(T), not move(T).
   13
   14at(T1, S1) :-
   15    move(T),
   16    stepsize(St),
   17    T1 .=. T - 1,
   18    S1 .=. St + S,
   19    at(T, S).
   20
   21at(T1, S) :-
   22    not move(T),
   23    step(T),
   24    T1 .=. T - 1,
   25    step(T1),
   26    at(T, S).
   27
   28% :- end(E), S .=<. 100, at(E,S).