Skip to content

Commit

Permalink
factors.pl
Browse files Browse the repository at this point in the history
  • Loading branch information
flach committed Feb 24, 2017
1 parent 5bef489 commit f333457
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
17 changes: 17 additions & 0 deletions factors.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
% factors(N,Fs) <- Fs is the list of prime factors of N
factors(1,[1]).
factors(X,[Factor|Fs]) :-
X > 1,
between(2,X,Factor), % generate candidate factor, lowest first
(X mod Factor) =:= 0, % test Factor is divisor of X
!, % if so, stop generating!
Rem is X // Factor, % proceed with remainder
factors(Rem,Fs).

/** &lt;examples&gt;
?-factors(27,Fs).
?-factors(28,Fs).
?-factors(29,Fs).
*/
6 changes: 3 additions & 3 deletions tiles.pl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
board_size(7). % odd number, at least 3
board_size(9). % odd number, at least 3

eval_pos(Pos,Value):-
%% uncomment exactly one of the following lines
bLeftOfw(Pos,Value).
%outOfPlace(Pos,1,Value).
%bLeftOfw(Pos,Value).
outOfPlace(Pos,1,Value).

/*
* Moves are represented as triples m(From,To,Cost).
Expand Down

0 comments on commit f333457

Please sign in to comment.