diff options
| author | Adam Russell <ac.russell@live.com> | 2021-04-25 12:14:34 -0400 |
|---|---|---|
| committer | Adam Russell <ac.russell@live.com> | 2021-04-25 12:14:34 -0400 |
| commit | b4ee212c0029aa0aedbefdf161fc9700349b236a (patch) | |
| tree | b103cc0267e019646b7910a221ef4bfda8987403 | |
| parent | c08186dfa8428ca980a8c66f71731a06aa47a3f0 (diff) | |
| download | perlweeklychallenge-club-b4ee212c0029aa0aedbefdf161fc9700349b236a.tar.gz perlweeklychallenge-club-b4ee212c0029aa0aedbefdf161fc9700349b236a.tar.bz2 perlweeklychallenge-club-b4ee212c0029aa0aedbefdf161fc9700349b236a.zip | |
Perl and Prolog solutions, with blog links.
| -rw-r--r-- | challenge-109/adam-russell/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-109/adam-russell/blog1.txt | 1 | ||||
| -rw-r--r-- | challenge-109/adam-russell/perl/ch-2.pl | 5 | ||||
| -rw-r--r-- | challenge-109/adam-russell/prolog/ch-2.p | 18 |
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). |
