diff options
| author | Asher Harvey-Smith <asherharveysmith@gmail.com> | 2024-03-19 14:52:03 +0000 |
|---|---|---|
| committer | Asher Harvey-Smith <asherharveysmith@gmail.com> | 2024-03-19 14:52:03 +0000 |
| commit | e9c2946bf8e7d2b0e571a03ee44da5e4c6af3cdb (patch) | |
| tree | 4102e7c4b55e55beb695510c218da7203edcb482 | |
| parent | b91a4623cd4c2b51f779f59b53310a0bd745f03f (diff) | |
| download | perlweeklychallenge-club-e9c2946bf8e7d2b0e571a03ee44da5e4c6af3cdb.tar.gz perlweeklychallenge-club-e9c2946bf8e7d2b0e571a03ee44da5e4c6af3cdb.tar.bz2 perlweeklychallenge-club-e9c2946bf8e7d2b0e571a03ee44da5e4c6af3cdb.zip | |
raku solutions
| -rw-r--r-- | challenge-261/asherbhs/ch-1.raku | 8 | ||||
| -rw-r--r-- | challenge-261/asherbhs/ch-2.raku | 9 |
2 files changed, 17 insertions, 0 deletions
diff --git a/challenge-261/asherbhs/ch-1.raku b/challenge-261/asherbhs/ch-1.raku new file mode 100644 index 0000000000..ef62ff6e85 --- /dev/null +++ b/challenge-261/asherbhs/ch-1.raku @@ -0,0 +1,8 @@ +sub element-digit-sum(Int @ints --> Int) { + return abs @ints.sum - @ints».polymod(10 xx ∞)».sum.sum +} + +say element-digit-sum Array[Int].new(1, 2, 3, 45); +say element-digit-sum Array[Int].new(1, 12, 3); +say element-digit-sum Array[Int].new(1, 2, 3, 4); +say element-digit-sum Array[Int].new(236, 416, 336, 350); diff --git a/challenge-261/asherbhs/ch-2.raku b/challenge-261/asherbhs/ch-2.raku new file mode 100644 index 0000000000..2a1edcf4e6 --- /dev/null +++ b/challenge-261/asherbhs/ch-2.raku @@ -0,0 +1,9 @@ +sub multiply-by-two(Int @ints, Int $start --> Int) { + return $start ∈ @ints + ?? multiply-by-two(@ints, 2 * $start) + !! $start +} + +say multiply-by-two(Array[Int].new(5, 3, 6, 1, 12), 3); +say multiply-by-two(Array[Int].new(1, 2, 4, 3), 1); +say multiply-by-two(Array[Int].new(5, 6, 7), 2); |
