aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2022-05-07 00:16:43 +0100
committerGitHub <noreply@github.com>2022-05-07 00:16:43 +0100
commite5920bea3d97621fa172aaec90c96437982e2d0e (patch)
tree2601f3922100f9772530c48e0395aa0b35ba63c0
parent30b4c5ea730508c96c940c0ddd180ed53c173221 (diff)
parent9ae66bdecda2cfa192a1a5c0fece7d6b7c6394b8 (diff)
downloadperlweeklychallenge-club-e5920bea3d97621fa172aaec90c96437982e2d0e.tar.gz
perlweeklychallenge-club-e5920bea3d97621fa172aaec90c96437982e2d0e.tar.bz2
perlweeklychallenge-club-e5920bea3d97621fa172aaec90c96437982e2d0e.zip
Merge pull request #6052 from codereport/master
Week 163 P2 in APL
-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