aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author冯昶 <fengchang@novel-supertv.com>2023-02-27 18:39:20 +0800
committer冯昶 <fengchang@novel-supertv.com>2023-02-27 18:39:20 +0800
commitd2cca4f3533f095d018affa34893ac385b6b02af (patch)
treef153c4f03b4dd395b143913b6f27be70a9d9b663
parent0be97cae01f3155e252d7dd7c307763e41f2d10f (diff)
downloadperlweeklychallenge-club-d2cca4f3533f095d018affa34893ac385b6b02af.tar.gz
perlweeklychallenge-club-d2cca4f3533f095d018affa34893ac385b6b02af.tar.bz2
perlweeklychallenge-club-d2cca4f3533f095d018affa34893ac385b6b02af.zip
challenge 206, raku solutions
-rwxr-xr-xchallenge-206/feng-chang/raku/ch-1.raku12
-rwxr-xr-xchallenge-206/feng-chang/raku/ch-2.raku5
2 files changed, 17 insertions, 0 deletions
diff --git a/challenge-206/feng-chang/raku/ch-1.raku b/challenge-206/feng-chang/raku/ch-1.raku
new file mode 100755
index 0000000000..d1679698b7
--- /dev/null
+++ b/challenge-206/feng-chang/raku/ch-1.raku
@@ -0,0 +1,12 @@
+#!/bin/env raku
+
+unit sub MAIN(*@T);
+
+my $today = now.Date;
+my $tomorrow = $today.later(days => 1);
+
+my @instants = @T.map({ "{$today.yyyy-mm-dd}T{$_}:00".DateTime });
+@instants.push($_) for @T.map({ "{$tomorrow.yyyy-mm-dd}T{$_}:00".DateTime });
+@instants .= sort;
+
+put (^(+@instants-1)).map({ (@instants[$_+1] - @instants[$_]) / 60 }).min;
diff --git a/challenge-206/feng-chang/raku/ch-2.raku b/challenge-206/feng-chang/raku/ch-2.raku
new file mode 100755
index 0000000000..08056bb905
--- /dev/null
+++ b/challenge-206/feng-chang/raku/ch-2.raku
@@ -0,0 +1,5 @@
+#!/bin/env raku
+
+unit sub MAIN(*@N where +* %% 2);
+
+put @N.sort[0, 2 ... (+@N-2)].sum;