aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-151/wambash/raku/ch-2.raku21
1 files changed, 21 insertions, 0 deletions
diff --git a/challenge-151/wambash/raku/ch-2.raku b/challenge-151/wambash/raku/ch-2.raku
new file mode 100644
index 0000000000..5667a0cee7
--- /dev/null
+++ b/challenge-151/wambash/raku/ch-2.raku
@@ -0,0 +1,21 @@
+#!#!/usr/bin/env raku
+use experimental :cached;
+proto rob-the-house (+@) is cached {*};
+multi rob-the-house (+@ where Empty) {0}
+multi rob-the-house (+@ ($a)) {$a}
+multi rob-the-house(+@ ($h, **@t ($,**@tt))) {
+ rob-the-house(@t) max ($h+rob-the-house(@tt))
+}
+
+multi MAIN (Bool :test($)!) {
+ use Test;
+ is rob-the-house(), 0;
+ is rob-the-house(3),3;
+ is rob-the-house(2, 4, 5), 7;
+ is rob-the-house(4, 2, 3, 6, 5, 3), 13;
+ done-testing;
+}
+
+multi MAIN (*@a) {
+ say rob-the-house @a;
+}