diff options
| author | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2024-08-05 20:01:22 +0100 |
|---|---|---|
| committer | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2024-08-05 20:01:22 +0100 |
| commit | 524012f041fc882afc4b0aeda4e1bffae33d7ae7 (patch) | |
| tree | c84da7672b0675dbf441185e5adc7ff0f6d01767 /challenge-281 | |
| parent | c0a61d89e8d35ef4c35b8eabff80d959925f5761 (diff) | |
| download | perlweeklychallenge-club-524012f041fc882afc4b0aeda4e1bffae33d7ae7.tar.gz perlweeklychallenge-club-524012f041fc882afc4b0aeda4e1bffae33d7ae7.tar.bz2 perlweeklychallenge-club-524012f041fc882afc4b0aeda4e1bffae33d7ae7.zip | |
- Added solutions by Mariano Ortega.
- Added solutions by Laurent Rosenfeld.
- Added solutions by E. Choroba.
- Added solutions by Jan Krnavek.
Diffstat (limited to 'challenge-281')
| -rw-r--r-- | challenge-281/laurent-rosenfeld/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-281/laurent-rosenfeld/perl/ch-1.pl | 16 | ||||
| -rw-r--r-- | challenge-281/laurent-rosenfeld/raku/ch-1.raku | 15 |
3 files changed, 32 insertions, 0 deletions
diff --git a/challenge-281/laurent-rosenfeld/blog.txt b/challenge-281/laurent-rosenfeld/blog.txt new file mode 100644 index 0000000000..ff1dfbd91a --- /dev/null +++ b/challenge-281/laurent-rosenfeld/blog.txt @@ -0,0 +1 @@ +https://blogs.perl.org/users/laurent_r/2024/08/perl-weekly-challenge-281-check-color.html diff --git a/challenge-281/laurent-rosenfeld/perl/ch-1.pl b/challenge-281/laurent-rosenfeld/perl/ch-1.pl new file mode 100644 index 0000000000..7e82b7fa65 --- /dev/null +++ b/challenge-281/laurent-rosenfeld/perl/ch-1.pl @@ -0,0 +1,16 @@ +use strict; +use warnings; +use feature 'say'; + +sub check_color { + my ($abscissa, $ordinate) = split //, shift; + my $code = 1; + $code = 0 if $abscissa =~ /[aceg]/; + return "True" if ($code + $ordinate) % 2 == 0; + return "False"; +} + +for my $coordinates (qw<a1 d3 g5 e6 h8>) { + printf "%-2s => ", $coordinates; + say check_color $coordinates; +} diff --git a/challenge-281/laurent-rosenfeld/raku/ch-1.raku b/challenge-281/laurent-rosenfeld/raku/ch-1.raku new file mode 100644 index 0000000000..8bb4e7be27 --- /dev/null +++ b/challenge-281/laurent-rosenfeld/raku/ch-1.raku @@ -0,0 +1,15 @@ +sub check-color ($in) { + my ($abscissa, $ordinate) = $in.comb;` + my $code; + given $abscissa { + when /<[aceg]>/ {$code = 0} + when /<[bdfh]>/ {$code = 1} + } + return True if ($code + $ordinate) %% 2; + False; +} + +for <a1 d3 g5 e6 h8> -> $coordinates { + printf "%-2s => ", $coordinates; + say check-color $coordinates; +} |
