aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAugie De Blieck Jr <augiedb@gmail.com>2023-10-29 11:40:13 -0400
committerAugie De Blieck Jr <augiedb@gmail.com>2023-10-29 11:40:13 -0400
commit3015f29b69459f52276877a6b34bed615a6fbb99 (patch)
treeb962837c000d03a2ee65b313a419d9f28e9f7664
parent67310476fd1daa9d74365ca666f4f6d9a0932d50 (diff)
downloadperlweeklychallenge-club-3015f29b69459f52276877a6b34bed615a6fbb99.tar.gz
perlweeklychallenge-club-3015f29b69459f52276877a6b34bed615a6fbb99.tar.bz2
perlweeklychallenge-club-3015f29b69459f52276877a6b34bed615a6fbb99.zip
Weekly Challenge solutions for AugieDB
-rw-r--r--challenge-240/augiedb/perl/ch-1.pl15
-rw-r--r--challenge-240/augiedb/perl/ch-2.pl56
2 files changed, 71 insertions, 0 deletions
diff --git a/challenge-240/augiedb/perl/ch-1.pl b/challenge-240/augiedb/perl/ch-1.pl
new file mode 100644
index 0000000000..11820f512e
--- /dev/null
+++ b/challenge-240/augiedb/perl/ch-1.pl
@@ -0,0 +1,15 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+##
+## Just wanted to highlight a one-line solution to the problem.
+## I'm not rigging up a main() and a series of tests.
+## Trust me; it works. =)
+##
+
+my @string = ("Perl", "Python", "Pascal");
+my $chk = "ppp";
+
+print $chk eq join('', map { lc( substr($_, 0, 1) ) } @string ) ? "True" : "False";
+
diff --git a/challenge-240/augiedb/perl/ch-2.pl b/challenge-240/augiedb/perl/ch-2.pl
new file mode 100644
index 0000000000..a4c8b5b81e
--- /dev/null
+++ b/challenge-240/augiedb/perl/ch-2.pl
@@ -0,0 +1,56 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+##
+##
+## The real solution to this challenge is
+## one line in the build_array() subroutine.
+##
+## Skip head to line 32 for that.
+##
+
+main( (0, 2, 1, 5, 3, 4) );
+main( (5, 0, 1, 2, 3, 4) );
+
+sub main {
+
+ my @int = @_;
+
+ print "Input: ";
+ pretty_print_array( @int );
+ print "Output: ";
+ pretty_print_array( build_array( @int ) );
+ print "\n";
+
+}
+
+sub build_array {
+
+ my @int = @_;
+
+ return map{ $int[$_] } @int;
+
+}
+
+sub pretty_print_array {
+
+ my @array = @_;
+ my $length = scalar @array;
+ my $count = 1;
+
+ print "(";
+
+ foreach my $value(@array) {
+ print $value;
+ print ", " if $count < $length;
+ $count++;
+ }
+
+ print ")\n";
+
+ return;
+}
+
+
+