From b0257db0d734f63a09779995ebedf01f7c9b2ebe Mon Sep 17 00:00:00 2001 From: Andrew Shitov Date: Mon, 16 Aug 2021 22:35:18 +0200 Subject: Week 126, task 1 by ash --- challenge-126/ash/README | 1 + challenge-126/ash/raku/ch-1.raku | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 challenge-126/ash/README create mode 100644 challenge-126/ash/raku/ch-1.raku (limited to 'challenge-126') diff --git a/challenge-126/ash/README b/challenge-126/ash/README new file mode 100644 index 0000000000..318b1bfb41 --- /dev/null +++ b/challenge-126/ash/README @@ -0,0 +1 @@ +Solutions by Andrew Shitov diff --git a/challenge-126/ash/raku/ch-1.raku b/challenge-126/ash/raku/ch-1.raku new file mode 100644 index 0000000000..d1c42c4796 --- /dev/null +++ b/challenge-126/ash/raku/ch-1.raku @@ -0,0 +1,18 @@ +sub count($n) { + my @items = (2..$n).grep: * !~~ /1/; + if @items { + if @items.elems == 1 { + say "There is 1 number between 1 and $n that doesn't contain digit 1."; + } + else { + 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."; + } +} + +.&count for 5, 15, 25; -- cgit