aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-261/asherbhs/ch-1.raku8
-rw-r--r--challenge-261/asherbhs/ch-2.raku9
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);