diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-11-06 20:29:08 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-06 20:29:08 +0000 |
| commit | 20e70fe9b07d48ac35eb18fef6c70cf0cb31d470 (patch) | |
| tree | 6b7aa9b17faa40aaee28dd13f4e8244834cd6625 | |
| parent | ae44d120ab0839d8e8651e8960a6b3ad626f5b44 (diff) | |
| parent | 13a69acc19e73ae62e674a145eabe0534ad71ad0 (diff) | |
| download | perlweeklychallenge-club-20e70fe9b07d48ac35eb18fef6c70cf0cb31d470.tar.gz perlweeklychallenge-club-20e70fe9b07d48ac35eb18fef6c70cf0cb31d470.tar.bz2 perlweeklychallenge-club-20e70fe9b07d48ac35eb18fef6c70cf0cb31d470.zip | |
Merge pull request #5169 from wambash/challenge-week-137
solutions week 137
| -rw-r--r-- | challenge-137/wambash/raku/ch-1.raku | 25 | ||||
| -rw-r--r-- | challenge-137/wambash/raku/ch-2.raku | 21 |
2 files changed, 46 insertions, 0 deletions
diff --git a/challenge-137/wambash/raku/ch-1.raku b/challenge-137/wambash/raku/ch-1.raku new file mode 100644 index 0000000000..4c8a578612 --- /dev/null +++ b/challenge-137/wambash/raku/ch-1.raku @@ -0,0 +1,25 @@ +#!/usr/bin/env raku + +enum DOW (Thursday => 4); + +sub is-long-year ($year ) { + | Date.new( :$year ) + | Date.new( year => $year+1)-1 + andthen .day-of-week == Thursday +} + +multi MAIN () { + 1900 .. 2100 + andthen Supply.from-list: $_ + andthen .grep: &is-long-year + andthen .batch: :5elems + andthen .map: *.fmt: '%4d', ', ' + andthen .tap: *.say; +} + +multi MAIN (Bool :test($)!) { + use Test; + ok is-long-year( $_ ) for 1903, 2032, 2099; + nok is-long-year( $_ ) for 1901, 2033, 2098; + done-testing; +} diff --git a/challenge-137/wambash/raku/ch-2.raku b/challenge-137/wambash/raku/ch-2.raku new file mode 100644 index 0000000000..c6df1ad300 --- /dev/null +++ b/challenge-137/wambash/raku/ch-2.raku @@ -0,0 +1,21 @@ +#!/usr/bin/env raku + + +sub is-Lychrel-number ($n) { + $n, {$_ + .flip} ... * >= 10_000_000 + andthen .head: 500 + andthen not .first: {$_ eq .flip}, :p +} + +multi MAIN ($n) { + say +is-Lychrel-number $n +} + +multi MAIN (Bool :test($)!) { + use Test; + nok is-Lychrel-number(56); + nok is-Lychrel-number(57); + nok is-Lychrel-number(59); + ok is-Lychrel-number(196); + done-testing; +} |
