diff options
| -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 ' '; +} |
