diff options
| author | SvetlanaNesterova <nesterova.svetlanka@yandex.ru> | 2019-10-20 17:11:56 +0500 |
|---|---|---|
| committer | SvetlanaNesterova <nesterova.svetlanka@yandex.ru> | 2019-10-20 17:11:56 +0500 |
| commit | a94f0198629782810670ea660469ee84ff7f52e3 (patch) | |
| tree | 1440d5c32bc97786a1509a2bd0711ed37f2bc6d4 /challenge-030 | |
| parent | a22e76e3c536995f1b35ba1c870df8664efe47b2 (diff) | |
| download | perlweeklychallenge-club-a94f0198629782810670ea660469ee84ff7f52e3.tar.gz perlweeklychallenge-club-a94f0198629782810670ea660469ee84ff7f52e3.tar.bz2 perlweeklychallenge-club-a94f0198629782810670ea660469ee84ff7f52e3.zip | |
Challenge 30
Diffstat (limited to 'challenge-030')
| -rw-r--r-- | challenge-030/svetlana-nesterova/README | 1 | ||||
| -rw-r--r-- | challenge-030/svetlana-nesterova/perl5/ch-1.pl | 24 | ||||
| -rw-r--r-- | challenge-030/svetlana-nesterova/perl5/ch-2.pl | 29 |
3 files changed, 54 insertions, 0 deletions
diff --git a/challenge-030/svetlana-nesterova/README b/challenge-030/svetlana-nesterova/README new file mode 100644 index 0000000000..d652fca3e7 --- /dev/null +++ b/challenge-030/svetlana-nesterova/README @@ -0,0 +1 @@ +Solution by Svetlana Nesterova
\ No newline at end of file diff --git a/challenge-030/svetlana-nesterova/perl5/ch-1.pl b/challenge-030/svetlana-nesterova/perl5/ch-1.pl new file mode 100644 index 0000000000..171adb0af7 --- /dev/null +++ b/challenge-030/svetlana-nesterova/perl5/ch-1.pl @@ -0,0 +1,24 @@ +#!/usr/bin/perl +use strict; +use warnings FATAL => 'all'; +use DateTime; +use DateTime::Format::HTTP; + +use constant SUNDAY => 7; + + +=Write a script to list dates for Sunday Christmas between 2019 and 2100. + For example, 25 Dec 2022 is Sunday. +=cut + + +sub PrintSundayChristmases() { + for my $year (2019 .. 2100) { + my $christmas = DateTime->new(year => $year, month => 12, day => 25); + if ($christmas->day_of_week == SUNDAY) { + print DateTime::Format::HTTP->format_datetime($christmas), "\n"; + } + } +} + +print PrintSundayChristmases(); diff --git a/challenge-030/svetlana-nesterova/perl5/ch-2.pl b/challenge-030/svetlana-nesterova/perl5/ch-2.pl new file mode 100644 index 0000000000..d27d3907f7 --- /dev/null +++ b/challenge-030/svetlana-nesterova/perl5/ch-2.pl @@ -0,0 +1,29 @@ +#!/usr/bin/perl +use strict; +use warnings FATAL => 'all'; + +use List::Util; + +=Write a script to print all possible series of 3 positive numbers, + where in each series at least one of the number is even and sum of the three numbers is always 12. + For example, 3,4,5. +=cut + + +sub PrintSeries() { + my $sum = 12; + + for my $i (1 .. $sum) { + for my $j ($i .. $sum) { + for my $k ($j .. $sum) { + if ($i + $j + $k == $sum) { + print qq($i $j $k \n); + } + } + } + } +} + + + +PrintSeries();
\ No newline at end of file |
