aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author冯昶 <seaker@qq.com>2021-11-01 16:40:13 +0800
committer冯昶 <seaker@qq.com>2021-11-01 16:40:13 +0800
commit543bce7e79f1e0c39b2755dd52962b409c7c15d0 (patch)
treeea0d9898a4c1c477e7542f7bb75e88233299a5b5
parent47c592ce79003fa05dc7f2d5d1f22c5ef2ff1b4e (diff)
downloadperlweeklychallenge-club-543bce7e79f1e0c39b2755dd52962b409c7c15d0.tar.gz
perlweeklychallenge-club-543bce7e79f1e0c39b2755dd52962b409c7c15d0.tar.bz2
perlweeklychallenge-club-543bce7e79f1e0c39b2755dd52962b409c7c15d0.zip
challenge 137, raku solutions
-rwxr-xr-xchallenge-137/feng-chang/raku/ch-1.raku7
-rwxr-xr-xchallenge-137/feng-chang/raku/ch-2.raku21
2 files changed, 28 insertions, 0 deletions
diff --git a/challenge-137/feng-chang/raku/ch-1.raku b/challenge-137/feng-chang/raku/ch-1.raku
new file mode 100755
index 0000000000..b0de7b2725
--- /dev/null
+++ b/challenge-137/feng-chang/raku/ch-1.raku
@@ -0,0 +1,7 @@
+#!/bin/env raku
+
+put (1900..2100)
+ .grep({ Date("$_-12-31").week[1] == 53 })
+ .rotor(5, :partial)
+ .map({ $_.join(', ') })
+ .join(",\n");
diff --git a/challenge-137/feng-chang/raku/ch-2.raku b/challenge-137/feng-chang/raku/ch-2.raku
new file mode 100755
index 0000000000..7239d2cdb2
--- /dev/null
+++ b/challenge-137/feng-chang/raku/ch-2.raku
@@ -0,0 +1,21 @@
+#!/bin/env raku
+
+sub is-palindrome(UInt:D $n --> Bool:D) { $n.flip == $n }
+
+sub is-lynchel(UInt:D $n --> Bool:D) {
+ my UInt $m = $n;
+ my UInt $cnt;
+
+ repeat {
+ return False if is-palindrome($m);
+
+ $m += $m.flip;
+ ++$cnt;
+ } while $cnt < 500;
+
+ ! is-palindrome($m)
+}
+
+sub MAIN(UInt:D $n) {
+ put +is-lynchel($n);
+}