diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2019-10-14 11:42:25 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-14 11:42:25 +0100 |
| commit | 9682e3f839b8ae33dc3afa3b235dd45d77c3e0c5 (patch) | |
| tree | 376d475264c6ebb97e8ee91c1a3bfe89fde0af5d /challenge-030 | |
| parent | 4f226fd177702edb95cda1b11153dfe8282c6f50 (diff) | |
| parent | 1c369c484fb5eda6a554541c3bb5b3ec81f38887 (diff) | |
| download | perlweeklychallenge-club-9682e3f839b8ae33dc3afa3b235dd45d77c3e0c5.tar.gz perlweeklychallenge-club-9682e3f839b8ae33dc3afa3b235dd45d77c3e0c5.tar.bz2 perlweeklychallenge-club-9682e3f839b8ae33dc3afa3b235dd45d77c3e0c5.zip | |
Merge pull request #766 from holli-holzer/master
Solutions by Markus Holzer
Diffstat (limited to 'challenge-030')
| -rw-r--r-- | challenge-030/markus-holzer/perl/ch-1.pl | 2 | ||||
| -rw-r--r-- | challenge-030/markus-holzer/perl/ch-2.pl | 14 | ||||
| -rw-r--r-- | challenge-030/markus-holzer/raku/ch-1.pl6 | 9 | ||||
| -rw-r--r-- | challenge-030/markus-holzer/raku/ch-2.pl6 | 8 |
4 files changed, 33 insertions, 0 deletions
diff --git a/challenge-030/markus-holzer/perl/ch-1.pl b/challenge-030/markus-holzer/perl/ch-1.pl new file mode 100644 index 0000000000..a0ca19f008 --- /dev/null +++ b/challenge-030/markus-holzer/perl/ch-1.pl @@ -0,0 +1,2 @@ +use Date::Christmas qw(christmasday); +print join "\n", grep { christmasday($_) eq "Sunday" } 2019 .. 2100;
\ No newline at end of file diff --git a/challenge-030/markus-holzer/perl/ch-2.pl b/challenge-030/markus-holzer/perl/ch-2.pl new file mode 100644 index 0000000000..3fefd797bb --- /dev/null +++ b/challenge-030/markus-holzer/perl/ch-2.pl @@ -0,0 +1,14 @@ +use Modern::Perl; +use List::Util qw( sum ); +use Set::Product qw( product ); +use Algorithm::Combinatorics qw( variations_with_repetition ); + +product { + my ( $even, $rest ) = @_; + + say join( ", ", $even, @$rest ) + if sum( $even, @$rest ) == 12; +} +[ 2, 4 .. 10 ], +[ variations_with_repetition( [1 .. 10], 2 ) ]; + diff --git a/challenge-030/markus-holzer/raku/ch-1.pl6 b/challenge-030/markus-holzer/raku/ch-1.pl6 new file mode 100644 index 0000000000..b37f214e88 --- /dev/null +++ b/challenge-030/markus-holzer/raku/ch-1.pl6 @@ -0,0 +1,9 @@ +constant \SUNDAY = 7; + +.say for + ( 2019 .. 2100 ) + .map( { DateTime.new( :$^year, month => 12, day => 25 ) }) + .grep( { .day-of-week == SUNDAY }) + .map( { .year }) +; + diff --git a/challenge-030/markus-holzer/raku/ch-2.pl6 b/challenge-030/markus-holzer/raku/ch-2.pl6 new file mode 100644 index 0000000000..59b4a773dd --- /dev/null +++ b/challenge-030/markus-holzer/raku/ch-2.pl6 @@ -0,0 +1,8 @@ +.say for + ( ( 2, 4 ... 10 ) X combinations( 1 .. 10, 2 ) ) + .map( { .flat.cache }) + .grep( { .sum == 12 }) + .map( { .join(", ") }) +; + +sub combinations( @combinatees, $places) { combinations( @combinatees, $places - 1 ) X @combinatees if $places > 0 }
\ No newline at end of file |
