aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYsmael Ebreo <Ysmael.Ebreo@latticesemi.com>2020-05-11 22:52:44 +0800
committerYsmael Ebreo <Ysmael.Ebreo@latticesemi.com>2020-05-11 22:52:44 +0800
commit1bd06dd5ebbb420d3eba4335a8d2c6b4d4eea520 (patch)
tree881044fe7cbb0346cd66e6a28f7c0065b84c5a98
parentad67d038ef0f7baeeea8d57d3353ebcd28333a73 (diff)
downloadperlweeklychallenge-club-1bd06dd5ebbb420d3eba4335a8d2c6b4d4eea520.tar.gz
perlweeklychallenge-club-1bd06dd5ebbb420d3eba4335a8d2c6b4d4eea520.tar.bz2
perlweeklychallenge-club-1bd06dd5ebbb420d3eba4335a8d2c6b4d4eea520.zip
Added perl solution for ch#60
-rw-r--r--challenge-060/yet-ebreo/perl/ch-1.pl54
-rw-r--r--challenge-060/yet-ebreo/perl/ch-2.pl50
2 files changed, 104 insertions, 0 deletions
diff --git a/challenge-060/yet-ebreo/perl/ch-1.pl b/challenge-060/yet-ebreo/perl/ch-1.pl
new file mode 100644
index 0000000000..556dbc1ba4
--- /dev/null
+++ b/challenge-060/yet-ebreo/perl/ch-1.pl
@@ -0,0 +1,54 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use feature 'say';
+
+sub to_num {
+ (ord) - 64 + 26 * (&to_num||0) if $_ = chop @_
+}
+sub to_exl {
+ $% = pop;
+ while ($%>26) {
+ $" = chr (64 + $% - 26*($% /= 26)) . $";
+ }
+ chr(64 + $%).$"
+}
+my $excelcol = uc $ARGV[0];
+
+if ($excelcol=~/\D/) {
+ say to_num($excelcol);
+} else {
+ say to_exl($excelcol);
+}
+=begin
+perl .\ch-1.pl 1
+A
+
+perl .\ch-1.pl A
+1
+
+perl .\ch-1.pl 26
+Z
+
+perl .\ch-1.pl Z
+26
+
+perl .\ch-1.pl 661
+YK
+
+perl .\ch-1.pl YK
+661
+
+perl .\ch-1.pl 16384
+XFD
+
+perl .\ch-1.pl XFD
+16384
+
+perl .\ch-1.pl 214358502
+RABBIT
+
+perl .\ch-1.pl RABBIT
+214358502
+
+=cut \ No newline at end of file
diff --git a/challenge-060/yet-ebreo/perl/ch-2.pl b/challenge-060/yet-ebreo/perl/ch-2.pl
new file mode 100644
index 0000000000..79ec00f0a4
--- /dev/null
+++ b/challenge-060/yet-ebreo/perl/ch-2.pl
@@ -0,0 +1,50 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use feature 'say';
+use Algorithm::Combinatorics qw(variations);
+
+my @L = (0, 1, 2, 5);
+my $X = 2;
+my $Y = 21;
+if (@ARGV > 2) {
+ $Y = pop @ARGV;
+ $X = pop @ARGV;
+ @L = @ARGV;
+}
+
+say @{$_} for grep {
+ (($X == length ($% = join "",@{$_})) && ($% < $Y))
+} variations(\@L,$X);
+
+=begin
+perl .\ch-2.pl
+10
+12
+15
+20
+
+perl .\ch-2.pl 0 1 3 9 1 5
+0
+1
+3
+
+perl .\ch-2.pl 0 1 3 9 2 20
+10
+13
+19
+
+perl .\ch-2.pl 0 1 3 9 3 600
+103
+109
+130
+139
+190
+193
+301
+309
+310
+319
+390
+391
+=cut \ No newline at end of file