diff options
| -rw-r--r-- | challenge-138/steven-wilson/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-138/steven-wilson/perl/ch-1.pl | 31 | ||||
| -rw-r--r-- | challenge-138/steven-wilson/python/ch-1.py | 28 |
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)]) |
