diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2024-08-10 19:08:52 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-10 19:08:52 +0100 |
| commit | 3deb10c03254b19f58d79c1468ced85d5abb5b09 (patch) | |
| tree | eed35715fac808c2bd45aeabe27c6df78895d622 | |
| parent | 4cae80b38ea97bc3c965f3a5b13fa04f2d550420 (diff) | |
| parent | 0897ce8b47344112a0dcfe12b3c0917317e09555 (diff) | |
| download | perlweeklychallenge-club-3deb10c03254b19f58d79c1468ced85d5abb5b09.tar.gz perlweeklychallenge-club-3deb10c03254b19f58d79c1468ced85d5abb5b09.tar.bz2 perlweeklychallenge-club-3deb10c03254b19f58d79c1468ced85d5abb5b09.zip | |
Merge pull request #10574 from ntovar/branch-281
Challenge 281. Add Perl (ch-1) and Bash (ch-1) solutions. By Nelo Tovar
| -rwxr-xr-x | challenge-281/nelo-tovar/bash/ch-1.sh | 28 | ||||
| -rw-r--r-- | challenge-281/nelo-tovar/perl/ch-1.pl | 30 |
2 files changed, 58 insertions, 0 deletions
diff --git a/challenge-281/nelo-tovar/bash/ch-1.sh b/challenge-281/nelo-tovar/bash/ch-1.sh new file mode 100755 index 0000000000..2be89a62a2 --- /dev/null +++ b/challenge-281/nelo-tovar/bash/ch-1.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# +# The Weekly Challenge 281 - By Nelo Tovar +# +# https://theweeklychallenge.org/blog/perl-weekly-challenge-281/ +# +# Task 1 - Check Color + +function check_color() { + local coordinates=$1 + + if [[ $coordinates =~ [aceg][1357] ]]; then + echo 'false' + else + echo 'true' + fi +} + +examples=('d3' 'g5' 'e6') + +for e in ${examples[@]}; do + array=($e) + cc=($(check_color $e)) + echo "Input : coordinates = $e" + echo "Output : $cc" + echo "" +done + diff --git a/challenge-281/nelo-tovar/perl/ch-1.pl b/challenge-281/nelo-tovar/perl/ch-1.pl new file mode 100644 index 0000000000..c603eb2aac --- /dev/null +++ b/challenge-281/nelo-tovar/perl/ch-1.pl @@ -0,0 +1,30 @@ +#!/usr/bin/env perl + +# The Weekly Challenge 281 - By Nelo Tovar +# +# https://theweeklychallenge.org/blog/perl-weekly-challenge-281/ +# +# Task 1 - Check Color +# + +use strict; +use warnings; +use v5.28; +use Data::Dump qw(dump); + +my @examples = ( 'd3', 'g5', 'e6'); + +sub check_color { + my $coordinates = shift; + + return ($coordinates =~ /[aceg][1357]/) ? 'false' : 'true'; + +} + +for my $elements (@examples) { + my $cc = check_color $elements; + + say 'Input : coordinates = ', $elements; + say 'Output : ', $cc; + say ' '; +} |
