diff options
| author | E. Choroba <choroba@matfyz.cz> | 2019-10-17 00:00:33 +0200 |
|---|---|---|
| committer | E. Choroba <choroba@matfyz.cz> | 2019-10-17 00:00:33 +0200 |
| commit | 8922dd9a0f325dd4bd0834b1031e682ac3225d08 (patch) | |
| tree | aec2258c84e7cd99dae98aa97bcefae67faad19d | |
| parent | deba8caba88c44f5f4d1ad8c8233bea21b838664 (diff) | |
| download | perlweeklychallenge-club-8922dd9a0f325dd4bd0834b1031e682ac3225d08.tar.gz perlweeklychallenge-club-8922dd9a0f325dd4bd0834b1031e682ac3225d08.tar.bz2 perlweeklychallenge-club-8922dd9a0f325dd4bd0834b1031e682ac3225d08.zip | |
Add solutions to 030 (Sum Series and Sunday Christmas) by E. Choroba
| -rwxr-xr-x | challenge-030/e-choroba/perl5/ch-1.pl | 26 | ||||
| -rwxr-xr-x | challenge-030/e-choroba/perl5/ch-2.pl | 19 |
2 files changed, 45 insertions, 0 deletions
diff --git a/challenge-030/e-choroba/perl5/ch-1.pl b/challenge-030/e-choroba/perl5/ch-1.pl new file mode 100755 index 0000000000..137e27231c --- /dev/null +++ b/challenge-030/e-choroba/perl5/ch-1.pl @@ -0,0 +1,26 @@ +#!/usr/bin/perl +use warnings; +use strict; +use feature qw{ say }; + +use Time::Piece; + +sub sunday_xmas { + my ($year) = @_; + return 0 == 'Time::Piece' + ->strptime("$year-12-25", '%Y-%m-%d') + ->day_of_week +} + +# use Test::More tests => 7; +# ok sunday_xmas(2022), '25 Dec 2022'; +# ok ! sunday_xmas(2021), '26 Dec 2021'; +# ok ! sunday_xmas(2020), '27 Dec 2020'; +# ok ! sunday_xmas(2025), '28 Dec 2025'; +# ok ! sunday_xmas(2019), '29 Dec 2019'; +# ok ! sunday_xmas(2029), '30 Dec 2029'; +# ok ! sunday_xmas(2023), '31 Dec 2023'; + +for my $year (2019 .. 2100) { + say "25 Dec $year" if sunday_xmas($year); +} diff --git a/challenge-030/e-choroba/perl5/ch-2.pl b/challenge-030/e-choroba/perl5/ch-2.pl new file mode 100755 index 0000000000..5a11614dd5 --- /dev/null +++ b/challenge-030/e-choroba/perl5/ch-2.pl @@ -0,0 +1,19 @@ +#!/usr/bin/perl +use warnings; +use strict; +use feature qw{ say }; + +for my $i (1 .. 10) { + for my $j ($i .. 10) { + last if $i + $j > 11; + + for my $k ($j .. 10) { + last if $i + $j + $k > 12; + + say "$i, $j, $k" + if $i + $j + $k == 12 +# && 0 == $i * $j * $k % 2 + } + } +} + |
