From 9ae66bdecda2cfa192a1a5c0fece7d6b7c6394b8 Mon Sep 17 00:00:00 2001 From: Conor Hoekstra Date: Tue, 3 May 2022 10:08:20 -0400 Subject: Week 163 P2 in APL --- challenge-163/conor-hoekstra/ch-2.apl | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 challenge-163/conor-hoekstra/ch-2.apl 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 -- cgit