aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-11-12 01:01:22 +0000
committerGitHub <noreply@github.com>2021-11-12 01:01:22 +0000
commit48669c7035d100ba47cbcc1d6477ad332e8cc9e9 (patch)
tree7f0e56762ebc7db79e97c0ec22e620dcce5e0207
parent8c6baf09f0fcec80f376408a97e72c592048af2f (diff)
parentbe86b9ef633c6e7f18ae75036e19fee2be1e270f (diff)
downloadperlweeklychallenge-club-48669c7035d100ba47cbcc1d6477ad332e8cc9e9.tar.gz
perlweeklychallenge-club-48669c7035d100ba47cbcc1d6477ad332e8cc9e9.tar.bz2
perlweeklychallenge-club-48669c7035d100ba47cbcc1d6477ad332e8cc9e9.zip
Merge pull request #5197 from oWnOIzRi/week138
add solution week 138 task 1 in perl and blog
-rw-r--r--challenge-138/steven-wilson/blog.txt1
-rw-r--r--challenge-138/steven-wilson/perl/ch-1.pl31
-rw-r--r--challenge-138/steven-wilson/python/ch-1.py28
3 files changed, 60 insertions, 0 deletions
diff --git a/challenge-138/steven-wilson/blog.txt b/challenge-138/steven-wilson/blog.txt
new file mode 100644
index 0000000000..11700f6fe6
--- /dev/null
+++ b/challenge-138/steven-wilson/blog.txt
@@ -0,0 +1 @@
+https://tilde.town/~wlsn/pwc138.html
diff --git a/challenge-138/steven-wilson/perl/ch-1.pl b/challenge-138/steven-wilson/perl/ch-1.pl
new file mode 100644
index 0000000000..60ba8d6960
--- /dev/null
+++ b/challenge-138/steven-wilson/perl/ch-1.pl
@@ -0,0 +1,31 @@
+#!/usr/bin/env perl
+# Week 138 Task 1
+# Workdays
+
+use strict;
+use warnings;
+use feature qw/ say /;
+use DateTime;
+
+my $year = $ARGV[0];
+my $dt = DateTime->new( year => $year, month => 1, day => 1 );
+my $start_day_of_week = $dt->day_of_week();
+my $is_leap_year = $dt->is_leap_year();
+my %workdays = (
+ 10 => 261,
+ 11 => 262,
+ 20 => 261,
+ 21 => 262,
+ 30 => 261,
+ 31 => 262,
+ 40 => 261,
+ 41 => 262,
+ 50 => 261,
+ 51 => 261,
+ 60 => 260,
+ 61 => 260,
+ 70 => 260,
+ 71 => 261,
+);
+
+say $workdays{"$start_day_of_week$is_leap_year"};
diff --git a/challenge-138/steven-wilson/python/ch-1.py b/challenge-138/steven-wilson/python/ch-1.py
new file mode 100644
index 0000000000..86c369ea46
--- /dev/null
+++ b/challenge-138/steven-wilson/python/ch-1.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+
+import sys
+import datetime
+import calendar
+
+year = int(sys.argv[1])
+day = datetime.datetime(year, 1, 1)
+week_day = day.isoweekday()
+is_leap_year = int(calendar.isleap(year))
+workdays = {
+ '10': 261,
+ '11': 262,
+ '20': 261,
+ '21': 262,
+ '30': 261,
+ '31': 262,
+ '40': 261,
+ '41': 262,
+ '50': 261,
+ '51': 261,
+ '60': 260,
+ '61': 260,
+ '70': 260,
+ '71': 261,
+}
+
+print(workdays[str(week_day) + str(is_leap_year)])