aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-281/santiago-leyva/perl/ch-01.pl36
-rw-r--r--challenge-281/santiago-leyva/perl/ch-02.pl15
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