aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-163/conor-hoekstra/ch-2.apl27
1 files changed, 27 insertions, 0 deletions
diff --git a/challenge-163/conor-hoekstra/ch-2.apl b/challenge-163/conor-hoekstra/ch-2.apl
new file mode 100644
index 0000000000..834ff7f4a5
--- /dev/null
+++ b/challenge-163/conor-hoekstra/ch-2.apl
@@ -0,0 +1,27 @@
+ summations ← {⊖⌽⍤1↑⍕¨¨⌽¨1↓{⍵,⍨⊂+\1↓⊃⍵}⍣(≢⍵)⊂⍵}
+
+ ⍝ Tests
+ summations 1 2 3 4 5
+┌──┬──┬──┬──┬──┐
+│1 │2 │3 │4 │5 │
+├──┼──┼──┼──┼──┤
+│ │2 │5 │9 │14│
+├──┼──┼──┼──┼──┤
+│ │ │5 │14│28│
+├──┼──┼──┼──┼──┤
+│ │ │ │14│42│
+├──┼──┼──┼──┼──┤
+│ │ │ │ │42│
+└──┴──┴──┴──┴──┘
+ summations 1 3 5 7 9
+┌──┬──┬──┬──┬──┐
+│1 │3 │5 │7 │9 │
+├──┼──┼──┼──┼──┤
+│ │3 │8 │15│24│
+├──┼──┼──┼──┼──┤
+│ │ │8 │23│47│
+├──┼──┼──┼──┼──┤
+│ │ │ │23│70│
+├──┼──┼──┼──┼──┤
+│ │ │ │ │70│
+└──┴──┴──┴──┴──┘ \ No newline at end of file