From 885881b4ab9d9305541f1678668fd595727997af Mon Sep 17 00:00:00 2001 From: Daniel Mita Date: Sat, 7 Dec 2019 07:55:37 +0000 Subject: Add solutions for challenge-037-1 in Raku/Perl/Go --- challenge-037/daniel-mita/go/ch-1.go | 28 ++++++++++++++++++++++++++++ challenge-037/daniel-mita/perl5/ch-1.pl | 18 ++++++++++++++++++ challenge-037/daniel-mita/perl6/ch-1.p6 | 15 +++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 challenge-037/daniel-mita/go/ch-1.go create mode 100755 challenge-037/daniel-mita/perl5/ch-1.pl create mode 100755 challenge-037/daniel-mita/perl6/ch-1.p6 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; +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; + $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} }); -- cgit