Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.90 KB | None | 0 0
  1. [kattio].
  2.  
  3. main :-
  4.     read_int(X),
  5.     (myfunc(X, 0) -> write(sucess) ; write(impossible), halt(0)).
  6.  
  7.  
  8. myfunc(0, _) :- !.
  9. myfunc(Count, _):- Count < 0, !, fail.
  10. myfunc(_, N):- N > 2, !, fail.
  11. myfunc(Count, N):- between(1, 20, Dart),
  12.                         Nu is N + 1,
  13.                         NewCount is (Count - 3*Dart),
  14.                         myfunc( NewCount, Nu),
  15.                         write(triple ), write(Dart), nl.
  16. myfunc(Count, N) :- between(1, 20, Dart),
  17.                         NewCount is (Count - 2*Dart),
  18.                         Nu is N + 1,
  19.                         myfunc( NewCount, Nu),
  20.                         write(tripel ), write(Dart), nl.
  21. myfunc(Count, N) :- between(1, 20, Dart),
  22.                         Nu is N + 1,
  23.                         NewCount is (Count - Dart),
  24.                         myfunc( NewCount, Nu),
  25.                         write(single ), write(Dart), nl.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement