diff options
| -rw-r--r-- | challenge-240/augiedb/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-240/augiedb/perl/ch-1.pl | 15 | ||||
| -rw-r--r-- | challenge-240/augiedb/perl/ch-2.pl | 56 |
3 files changed, 72 insertions, 0 deletions
diff --git a/challenge-240/augiedb/blog.txt b/challenge-240/augiedb/blog.txt new file mode 100644 index 0000000000..06b02443c1 --- /dev/null +++ b/challenge-240/augiedb/blog.txt @@ -0,0 +1 @@ +https://variousandsundry.com/an-attempt-to-simplify-fails-but-works/ 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; +} + + + |
