aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-109/adam-russell/blog.txt1
-rw-r--r--challenge-109/adam-russell/blog1.txt1
-rw-r--r--challenge-109/adam-russell/perl/ch-2.pl5
-rw-r--r--challenge-109/adam-russell/prolog/ch-2.p18
4 files changed, 22 insertions, 3 deletions
diff --git a/challenge-109/adam-russell/blog.txt b/challenge-109/adam-russell/blog.txt
index e69de29bb2..d6493ed274 100644
--- a/challenge-109/adam-russell/blog.txt
+++ b/challenge-109/adam-russell/blog.txt
@@ -0,0 +1 @@
+http://www.rabbitfarm.com/cgi-bin/blosxom/perl/2021/04/25
diff --git a/challenge-109/adam-russell/blog1.txt b/challenge-109/adam-russell/blog1.txt
index e69de29bb2..fdf5d4d2ea 100644
--- a/challenge-109/adam-russell/blog1.txt
+++ b/challenge-109/adam-russell/blog1.txt
@@ -0,0 +1 @@
+http://www.rabbitfarm.com/cgi-bin/blosxom/prolog/2021/04/25
diff --git a/challenge-109/adam-russell/perl/ch-2.pl b/challenge-109/adam-russell/perl/ch-2.pl
index 3278d340e3..3a57cfebd1 100644
--- a/challenge-109/adam-russell/perl/ch-2.pl
+++ b/challenge-109/adam-russell/perl/ch-2.pl
@@ -30,8 +30,9 @@ $prolog = new AI::Prolog($prolog);
$prolog->query("sums_in_squares([1,2,3,4,5,6,7], Squares).");
my $result;
+print join("\t", "a" .. "g") . "\n";
while ($result = $prolog->results()){
- print join(",", @{$result->[2]}) . "\n";
+ print join("\t", @{$result->[2]}) . "\n";
}
__DATA__
@@ -58,4 +59,4 @@ sums_in_squares(Numbers, [A, B, C, D, E, F, G]):-
Box4 is F + G,
Box1 == Box2,
Box2 == Box3,
- Box3 == Box4. \ No newline at end of file
+ Box3 == Box4.
diff --git a/challenge-109/adam-russell/prolog/ch-2.p b/challenge-109/adam-russell/prolog/ch-2.p
index f56e7aa1a9..3f7aafd6d6 100644
--- a/challenge-109/adam-russell/prolog/ch-2.p
+++ b/challenge-109/adam-russell/prolog/ch-2.p
@@ -21,6 +21,22 @@
:-initialization(main).
+print_with_tab([H|[]]):-
+ write(H), nl.
+print_with_tab([H|T]):-
+ write(H),
+ write('\t'),
+ print_with_tab(T).
+
+print_values([]).
+print_values([H|T]):-
+ print_with_tab(H),
+ print_values(T).
+
+print_solutions(Solutions):-
+ print_with_tab([a, b, c, d, e, f, g]),
+ print_values(Solutions).
+
all_unique(_, []).
all_unique(L, [V|T]) :-
fd_exactly(1, L, V),
@@ -63,4 +79,4 @@ sums_in_squares_fd(Numbers, [A, B, C, D, E, F, G]):-
main:-
setof(S, sums_in_squares_fd([1,2,3,4,5,6,7], S), Squares),
- write(Squares). \ No newline at end of file
+ print_solutions(Squares).