diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2024-08-17 21:06:06 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-17 21:06:06 +0100 |
| commit | 8642a99a03823f9aac81a742dd7447e2e9ad4d26 (patch) | |
| tree | 22353583b2f8b06960ef2b659c37871179d1aa7d | |
| parent | 348c624dd31892a1af47724d564d8163e5afd5c5 (diff) | |
| parent | 90b65e67814b30a06427740b70766744b2c8c792 (diff) | |
| download | perlweeklychallenge-club-8642a99a03823f9aac81a742dd7447e2e9ad4d26.tar.gz perlweeklychallenge-club-8642a99a03823f9aac81a742dd7447e2e9ad4d26.tar.bz2 perlweeklychallenge-club-8642a99a03823f9aac81a742dd7447e2e9ad4d26.zip | |
Merge pull request #10634 from DevSanti12/master
Added ch-01 but couldn't finish ch-02 :c
| -rw-r--r-- | challenge-281/santiago-leyva/perl/ch-01.pl | 36 | ||||
| -rw-r--r-- | challenge-281/santiago-leyva/perl/ch-02.pl | 15 |
2 files changed, 51 insertions, 0 deletions
diff --git a/challenge-281/santiago-leyva/perl/ch-01.pl b/challenge-281/santiago-leyva/perl/ch-01.pl new file mode 100644 index 0000000000..d8f1bb666e --- /dev/null +++ b/challenge-281/santiago-leyva/perl/ch-01.pl @@ -0,0 +1,36 @@ +=begin + +Write a script to return true if the square is light, and false if the square is dark. + +Example 1 +Input: $coordinates = "d3" +Output: true +Example 2 +Input: $coordinates = "g5" +Output: false +Example 3 +Input: $coordinates = "e6" +Output: true + +=cut + +use strict; +use warnings; +use Data::Dumper; +my @columns_let = ('a'..'h'); +my %letters; + +for(my $i=1; $i<=(scalar @columns_let);$i++){ + $letters{$columns_let[$i-1]} = $i; +} + +my @tiles = ('d3','g5','e6'); + +foreach(@tiles){ + my ($let,$num) = $_ =~ /(\w+)(\d+)/; + if( ($letters{$let} + $num) % 2 == 0 ){ + print "$let$num -> False\n"; + }else{ + print "$let$num -> True\n"; + } +}
\ No newline at end of file diff --git a/challenge-281/santiago-leyva/perl/ch-02.pl b/challenge-281/santiago-leyva/perl/ch-02.pl new file mode 100644 index 0000000000..fc45e169e2 --- /dev/null +++ b/challenge-281/santiago-leyva/perl/ch-02.pl @@ -0,0 +1,15 @@ +=begin + +Write a script to return true if the square is light, and false if the square is dark. + +Example 1 +Input: $coordinates = "d3" +Output: true +Example 2 +Input: $coordinates = "g5" +Output: false +Example 3 +Input: $coordinates = "e6" +Output: true + +=cut
\ No newline at end of file |
