aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2019-12-07 11:08:46 +0000
committerGitHub <noreply@github.com>2019-12-07 11:08:46 +0000
commit35cb71ed634b4ae523f5a7f15eb1e86bc43c4101 (patch)
tree72a31446e4ccad71816e4e3ddb93489f28b44164
parent20073cc28f3d2ae2901f9aeb8e75136ae9ffe4ba (diff)
parent885881b4ab9d9305541f1678668fd595727997af (diff)
downloadperlweeklychallenge-club-35cb71ed634b4ae523f5a7f15eb1e86bc43c4101.tar.gz
perlweeklychallenge-club-35cb71ed634b4ae523f5a7f15eb1e86bc43c4101.tar.bz2
perlweeklychallenge-club-35cb71ed634b4ae523f5a7f15eb1e86bc43c4101.zip
Merge pull request #1007 from mienaikage/037-1
Add solutions for challenge-037-1 in Raku/Perl/Go
-rw-r--r--challenge-037/daniel-mita/go/ch-1.go28
-rwxr-xr-xchallenge-037/daniel-mita/perl5/ch-1.pl18
-rwxr-xr-xchallenge-037/daniel-mita/perl6/ch-1.p615
3 files changed, 61 insertions, 0 deletions
diff --git a/challenge-037/daniel-mita/go/ch-1.go b/challenge-037/daniel-mita/go/ch-1.go
new file mode 100644
index 0000000000..aa8d7b721e
--- /dev/null
+++ b/challenge-037/daniel-mita/go/ch-1.go
@@ -0,0 +1,28 @@
+package main
+
+import (
+ "fmt"
+ "time"
+)
+
+const Year = 2019
+
+func main() {
+ t := time.Date(Year, time.January, 1, 0, 0, 0, 0, time.UTC)
+
+ var count uint
+ for t.Year() == Year {
+ if t.Weekday() != time.Saturday && t.Weekday() != time.Sunday {
+ count++
+ }
+
+ // Add 1 day
+ d, _ := time.ParseDuration("24h")
+ if t.Month() != t.Add(d).Month() {
+ fmt.Println(t.Month().String()+":", count)
+ count = 0
+ }
+ t = t.Add(d)
+ }
+
+}
diff --git a/challenge-037/daniel-mita/perl5/ch-1.pl b/challenge-037/daniel-mita/perl5/ch-1.pl
new file mode 100755
index 0000000000..d776f4e9ab
--- /dev/null
+++ b/challenge-037/daniel-mita/perl5/ch-1.pl
@@ -0,0 +1,18 @@
+#!/usr/bin/env perl
+
+use v5.30;
+use warnings;
+
+use List::Util qw<all>;
+use Time::Piece;
+use Time::Seconds;
+
+my %count;
+my $d = Time::Piece->strptime( 2019, '%Y' );
+
+while ( $d->year == 2019 ) {
+ $count{$d->month}++ if all { $d->day ne $_ } qw<Sat Sun>;
+ $d += ONE_DAY;
+}
+
+say "$_: $count{$_}" for Time::Piece::mon_list;
diff --git a/challenge-037/daniel-mita/perl6/ch-1.p6 b/challenge-037/daniel-mita/perl6/ch-1.p6
new file mode 100755
index 0000000000..c1ab893309
--- /dev/null
+++ b/challenge-037/daniel-mita/perl6/ch-1.p6
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl6
+
+enum Months «
+ :Jan(1) Feb Mar
+ Apr May Jun
+ Jul Aug Sep
+ Oct Nov Dec
+»;
+
+"$_.key(): $_.value()".say for (gather {
+ given Date.new(:2019year) {
+ take Months(.month) if .day-of-week ≠ 6|7;
+ &?BLOCK(.succ) if .succ.year == .year;
+ }
+}).Bag.pairs.sort({ ::{$^a.key} <=> ::{$^b.key} });