From 64cf331a84163d5c55ab51b3791835ad5a541e03 Mon Sep 17 00:00:00 2001 From: Jan Krňávek Date: Mon, 14 Feb 2022 17:29:50 +0100 Subject: solution week 151 --- challenge-151/wambash/raku/ch-2.raku | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 challenge-151/wambash/raku/ch-2.raku 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; +} -- cgit