aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-324/adam-russell/blog1.txt1
-rw-r--r--challenge-324/adam-russell/prolog/ch-1.p13
-rw-r--r--challenge-324/adam-russell/prolog/ch-2.p21
3 files changed, 35 insertions, 0 deletions
diff --git a/challenge-324/adam-russell/blog1.txt b/challenge-324/adam-russell/blog1.txt
new file mode 100644
index 0000000000..588a87cddc
--- /dev/null
+++ b/challenge-324/adam-russell/blog1.txt
@@ -0,0 +1 @@
+http://rabbitfarm.com/cgi-bin/blosxom/prolog/2025/06/08
diff --git a/challenge-324/adam-russell/prolog/ch-1.p b/challenge-324/adam-russell/prolog/ch-1.p
new file mode 100644
index 0000000000..1f463460af
--- /dev/null
+++ b/challenge-324/adam-russell/prolog/ch-1.p
@@ -0,0 +1,13 @@
+
+
+ create_array(_, 0, _, []).
+ create_array(L, Rows, Columns, [Row|T]) :-
+ create_row(L, Columns, Row, L1),
+ R is Rows - 1,
+ create_array(L1, R, Columns, T).
+
+ create_row(L, 0, [], L).
+ create_row([H|T], Columns, [H|Row], L) :-
+ C is Columns - 1,
+ create_row(T, C, Row, L).
+
diff --git a/challenge-324/adam-russell/prolog/ch-2.p b/challenge-324/adam-russell/prolog/ch-2.p
new file mode 100644
index 0000000000..0947aeb539
--- /dev/null
+++ b/challenge-324/adam-russell/prolog/ch-2.p
@@ -0,0 +1,21 @@
+
+
+ subtotal(Combined, X):-
+ X is Combined.
+
+
+ total_xor(L, Total):-
+ findall(S, (
+ sublist(S, L),
+ \+ S = []
+ ), SubLists),
+ maplist(combine, SubLists, Combined),
+ maplist(subtotal, Combined, SubTotals),
+ sum_list(SubTotals, Total).
+
+
+ combine([], 0).
+ combine([H|T], Combined):-
+ combine(T, Combined1),
+ Combined = xor(H, Combined1).
+