aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Russell <adamcrussell@outlook.com>2025-05-04 14:49:48 -0400
committerAdam Russell <adamcrussell@outlook.com>2025-05-04 14:49:48 -0400
commitdb8c735ff8ef74aca57f07c0d6e60a899477d1c7 (patch)
tree81e916c48fc67157a2f4940907579d973a10e545
parent6156023b1a4d00854924643ca8bdc3b5a43ba6df (diff)
downloadperlweeklychallenge-club-db8c735ff8ef74aca57f07c0d6e60a899477d1c7.tar.gz
perlweeklychallenge-club-db8c735ff8ef74aca57f07c0d6e60a899477d1c7.tar.bz2
perlweeklychallenge-club-db8c735ff8ef74aca57f07c0d6e60a899477d1c7.zip
Prolog solutions
-rw-r--r--challenge-319/adam-russell/blog1.txt1
-rw-r--r--challenge-319/adam-russell/prolog/ch-1.p23
-rw-r--r--challenge-319/adam-russell/prolog/ch-2.p14
3 files changed, 38 insertions, 0 deletions
diff --git a/challenge-319/adam-russell/blog1.txt b/challenge-319/adam-russell/blog1.txt
new file mode 100644
index 0000000000..00c6360c29
--- /dev/null
+++ b/challenge-319/adam-russell/blog1.txt
@@ -0,0 +1 @@
+http://www.rabbitfarm.com/cgi-bin/blosxom/prolog/2025/05/04
diff --git a/challenge-319/adam-russell/prolog/ch-1.p b/challenge-319/adam-russell/prolog/ch-1.p
new file mode 100644
index 0000000000..c319805a51
--- /dev/null
+++ b/challenge-319/adam-russell/prolog/ch-1.p
@@ -0,0 +1,23 @@
+
+
+ vowel(97). % a
+ vowel(101). % e
+ vowel(105). % i
+ vowel(111). % o
+ vowel(117). % u
+
+
+ start_end_vowel(Word, StartsEnds):-
+ ((nth(1, Word, FirstLetter),
+ vowel(FirstLetter));
+ (last(Word, LastLetter),
+ vowel(LastLetter))),
+ StartsEnds = true.
+ start_end_vowel(_, -1).
+
+
+ word_count(Words, Count):-
+ maplist(start_end_vowel, Words, StartsEndsAll),
+ delete(StartsEndsAll, -1, StartsEnds),
+ length(StartsEnds, Count).
+
diff --git a/challenge-319/adam-russell/prolog/ch-2.p b/challenge-319/adam-russell/prolog/ch-2.p
new file mode 100644
index 0000000000..83fc6eb2f3
--- /dev/null
+++ b/challenge-319/adam-russell/prolog/ch-2.p
@@ -0,0 +1,14 @@
+
+
+ minimum_common(List1, List2, MinimumCommon):-
+
+ subtract(List1, List2, Difference1),
+ subtract(List2, List1, Difference2),
+ append(Difference1, Difference2, Differences),
+ subtract(List1, Differences, Common),
+
+ length(Common, L),
+ L >= 1,
+ min_list(Common, MinimumCommon).
+ minimum_common(_, _, -1).
+