aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-126/ash/raku/ch-1.raku18
1 files changed, 9 insertions, 9 deletions
diff --git a/challenge-126/ash/raku/ch-1.raku b/challenge-126/ash/raku/ch-1.raku
index d1c42c4796..08d68052e4 100644
--- a/challenge-126/ash/raku/ch-1.raku
+++ b/challenge-126/ash/raku/ch-1.raku
@@ -1,18 +1,18 @@
sub count($n) {
my @items = (2..$n).grep: * !~~ /1/;
- if @items {
- if @items.elems == 1 {
+ given @items.elems {
+ when 0 {
+ say "There are no numbers up to $n that contain no digit 1.";
+ }
+ when 1 {
say "There is 1 number between 1 and $n that doesn't contain digit 1.";
}
- else {
+ default {
say "There are {+@items} numbers between 1 and $n that don't contain digit 1.";
}
-
- say @items.join(', ') ~ '.';
- }
- else {
- say "There are no numbers between 1 and $n that contain no digit 1.";
}
+
+ say @items.join(', ') ~ '.' if @items;
}
-.&count for 5, 15, 25;
+.&count for 1, 2, 5, 15, 25;