aboutsummaryrefslogtreecommitdiff
path: root/challenge-030
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2019-10-19 21:40:33 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2019-10-19 21:40:33 +0100
commitb44ff95fff0fb6f3b0a1182ad74d998b406ece31 (patch)
tree9efef6f90d9d6898deca5f0e2a23dae521a88738 /challenge-030
parent1ce1320579965be3dfea1086b2d141531bbfc8be (diff)
parente5787122949e05fd87a8c86e7c5f3b6ac0e4fc73 (diff)
downloadperlweeklychallenge-club-b44ff95fff0fb6f3b0a1182ad74d998b406ece31.tar.gz
perlweeklychallenge-club-b44ff95fff0fb6f3b0a1182ad74d998b406ece31.tar.bz2
perlweeklychallenge-club-b44ff95fff0fb6f3b0a1182ad74d998b406ece31.zip
Merge branch 'master' of https://github.com/manwar/perlweeklychallenge-club
Diffstat (limited to 'challenge-030')
-rw-r--r--challenge-030/maxim-kolodyazhny/ch-1.pl22
-rw-r--r--challenge-030/maxim-kolodyazhny/ch-2.pl28
2 files changed, 50 insertions, 0 deletions
diff --git a/challenge-030/maxim-kolodyazhny/ch-1.pl b/challenge-030/maxim-kolodyazhny/ch-1.pl
new file mode 100644
index 0000000000..46f0570ca0
--- /dev/null
+++ b/challenge-030/maxim-kolodyazhny/ch-1.pl
@@ -0,0 +1,22 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+sub same_wday {
+ my ( $year, $up_to ) = @_;
+
+ my %how_many2skip = (
+ 0 => 28,
+ 1 => 6,
+ 2 => 11,
+ 3 => 11,
+ );
+
+ while ( $year <= $up_to ) {
+ print "$year\n";
+ $year += $how_many2skip{ $year % 4 };
+ }
+}
+
+same_wday ( 2022, 2100 );
diff --git a/challenge-030/maxim-kolodyazhny/ch-2.pl b/challenge-030/maxim-kolodyazhny/ch-2.pl
new file mode 100644
index 0000000000..6c6ec1a278
--- /dev/null
+++ b/challenge-030/maxim-kolodyazhny/ch-2.pl
@@ -0,0 +1,28 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use List::Util qw( sum0 );
+
+use constant {
+ NUM_COUNT => 3,
+ REQUIRED_SUM => 12,
+};
+
+sub n {
+ my $depth = shift // 1;
+ my @nums = @_;
+
+ my $sum = sum0 @nums;
+
+ if ( $depth > NUM_COUNT || REQUIRED_SUM < $sum ) {
+
+ print "@nums\n" if $sum == REQUIRED_SUM;
+
+ return;
+ }
+ n( $depth + 1, @nums, $_ ) for 1 .. REQUIRED_SUM;
+}
+
+n();