aboutsummaryrefslogtreecommitdiff
path: root/challenge-014
diff options
context:
space:
mode:
authorDave Jacoby <jacoby.david@gmail.com>2019-06-27 16:16:40 -0400
committerDave Jacoby <jacoby.david@gmail.com>2019-06-27 16:16:40 -0400
commitb0898d6b9f102aa5f24df350ad9d87f21f37ba17 (patch)
tree9eb9be7876f92819943f2e36b55ec31aec11cdea /challenge-014
parentae17d3b757a6844dbf2842692b47392f057baa7c (diff)
parent7412f83547b291b434a7128660538f1675a80c82 (diff)
downloadperlweeklychallenge-club-b0898d6b9f102aa5f24df350ad9d87f21f37ba17.tar.gz
perlweeklychallenge-club-b0898d6b9f102aa5f24df350ad9d87f21f37ba17.tar.bz2
perlweeklychallenge-club-b0898d6b9f102aa5f24df350ad9d87f21f37ba17.zip
Merge branch 'master' of github.com:manwar/perlweeklychallenge-club
Diffstat (limited to 'challenge-014')
-rw-r--r--challenge-014/e-choroba/blog.txt1
-rwxr-xr-xchallenge-014/e-choroba/perl5/ch-2.pl2
-rwxr-xr-xchallenge-014/e-choroba/perl5/ch-2a.pl53
-rwxr-xr-xchallenge-014/feng-chang/perl5/ch-1.pl22
-rwxr-xr-xchallenge-014/feng-chang/perl5/ch-2.pl40
-rwxr-xr-xchallenge-014/feng-chang/perl6/ch-1.p618
-rwxr-xr-xchallenge-014/feng-chang/perl6/ch-2.p617
-rw-r--r--challenge-014/gustavo-chaves/perl5/README.pod42
-rwxr-xr-xchallenge-014/gustavo-chaves/perl5/ch-1-recursive.pl (renamed from challenge-014/gustavo-chaves/perl5/ch-1a.pl)28
-rwxr-xr-xchallenge-014/gustavo-chaves/perl5/ch-1.pl28
-rwxr-xr-xchallenge-014/gustavo-chaves/perl5/ch-2-all.pl40
-rwxr-xr-xchallenge-014/gustavo-chaves/perl5/ch-2.pl2
-rwxr-xr-xchallenge-014/gustavo-chaves/perl5/ch-extra.pl63
-rw-r--r--challenge-014/jaime/README37
-rw-r--r--challenge-014/jaime/perl5/ch-1.pl26
-rw-r--r--challenge-014/jaime/perl5/ch-2.pl20
-rw-r--r--challenge-014/neil-bowers/blog.txt1
-rw-r--r--challenge-014/shaun-pearce/README1
-rw-r--r--challenge-014/steven-wilson/blog.txt1
-rw-r--r--challenge-014/steven-wilson/perl5/README.md3
-rw-r--r--challenge-014/steven-wilson/perl5/ch-2.pl105
-rwxr-xr-xchallenge-014/walt-mankowski/perl5/ch-1.pl31
-rwxr-xr-xchallenge-014/walt-mankowski/perl5/ch-2.pl53
23 files changed, 569 insertions, 65 deletions
diff --git a/challenge-014/e-choroba/blog.txt b/challenge-014/e-choroba/blog.txt
new file mode 100644
index 0000000000..92de29c1a2
--- /dev/null
+++ b/challenge-014/e-choroba/blog.txt
@@ -0,0 +1 @@
+http://blogs.perl.org/users/e_choroba/2019/06/perl-weekly-challenge-014-van-eck-and-the-us-states.html
diff --git a/challenge-014/e-choroba/perl5/ch-2.pl b/challenge-014/e-choroba/perl5/ch-2.pl
index ca5a4dc3e8..514b92cdfe 100755
--- a/challenge-014/e-choroba/perl5/ch-2.pl
+++ b/challenge-014/e-choroba/perl5/ch-2.pl
@@ -18,8 +18,6 @@ while (my $word = <$in>) {
my $uc_word = uc $word;
my @pairs = $uc_word =~ /\G(..)/g;
- next if length $uc_word != 2 * @pairs;
-
next if grep ! exists $states{$_}, @pairs;
next if length($word) < length $longest[0];
diff --git a/challenge-014/e-choroba/perl5/ch-2a.pl b/challenge-014/e-choroba/perl5/ch-2a.pl
new file mode 100755
index 0000000000..65df78f69e
--- /dev/null
+++ b/challenge-014/e-choroba/perl5/ch-2a.pl
@@ -0,0 +1,53 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use feature qw{ say };
+
+use Cpanel::JSON::XS;
+
+my $json = <DATA>;
+
+my $data = Cpanel::JSON::XS->new->decode($json);
+my %by_initials;
+undef $by_initials{$data->{$_}{initials}}{$_} for keys %$data;
+
+my @longest = ([""]);
+while (my $word = <>) {
+ chomp $word;
+ $word = lc $word;
+ if (my @path = path($word, [])) {
+ if (length $word > length $longest[0][0]) {
+ @longest = ([$word, \@path]);
+ } elsif (length $word == length $longest[0][0]) {
+ push @longest, [$word, \@path];
+ }
+ }
+}
+
+say "$_->[0]: ", map { map "[@$_] ", @$_ } @{ $_->[1] } for @longest;
+
+
+sub path {
+ my ($rest, $path) = @_;
+
+ return [$path] if "" eq $rest;
+
+ my @solutions;
+ for my $length (1, 2) {
+ next if $length > length $rest;
+
+ my $prefix = substr $rest, 0, $length;
+ next unless exists $by_initials{$prefix};
+
+ for my $state (keys %{ $by_initials{$prefix} }) {
+ next if @$path
+ && ((grep $_ eq $state, @$path)
+ || ! grep $state eq $_,
+ @{ $data->{ $path->[-1] }{adjacent} });
+ push @solutions, path(substr($rest, $length), [ @$path, $state ]);
+ }
+ }
+ return @solutions
+}
+__DATA__
+{"AL":{"name":"Alabama","initials":"a","adjacent":["FL","GA","TN","MS"]},"AK":{"name":"Alaska","initials":"a","adjacent":[]},"AZ":{"name":"Arizona","initials":"a","adjacent":["NM","UT","NV","CA"]},"AR":{"name":"Arkansas","initials":"a","adjacent":["LA","MS","TN","MO","OK","TX"]},"CA":{"name":"California","initials":"c","adjacent":["AZ","NV","OR"]},"CO":{"name":"Colorado","initials":"c","adjacent":["NM","OK","KS","NE","WY","UT"]},"CT":{"name":"Connecticut","initials":"c","adjacent":["RI","MA","NY"]},"DE":{"name":"Delaware","initials":"d","adjacent":["NJ","PA","MD"]},"FL":{"name":"Florida","initials":"f","adjacent":["GA","AL"]},"GA":{"name":"Georgia","initials":"g","adjacent":["SC","NC","TN","AL","FL"]},"HI":{"name":"Hawaii","initials":"h","adjacent":[]},"ID":{"name":"Idaho","initials":"i","adjacent":["WA","OR","NV","UT","WY","MT"]},"IL":{"name":"Illinois","initials":"i","adjacent":["WI","IA","MO","KY","IN"]},"IN":{"name":"Indiana","initials":"i","adjacent":["IL","KY","OH","MI"]},"IA":{"name":"Iowa","initials":"i","adjacent":["MN","SD","NE","MO","IL","WI"]},"KS":{"name":"Kansas","initials":"k","adjacent":["OK","MO","NE","CO"]},"KY":{"name":"Kentucky","initials":"k","adjacent":["TN","VA","WV","OH","IN","IL","MO"]},"LA":{"name":"Louisiana","initials":"l","adjacent":["MS","AR","TX"]},"ME":{"name":"Maine","initials":"m","adjacent":["NH"]},"MD":{"name":"Maryland","initials":"m","adjacent":["DE","PA","WV","VA"]},"MA":{"name":"Massachusetts","initials":"m","adjacent":["NH","VT","NY","CT","RI"]},"MI":{"name":"Michigan","initials":"m","adjacent":["WI","IN","OH"]},"MN":{"name":"Minnesota","initials":"m","adjacent":["ND","SD","IA","WI"]},"MS":{"name":"Mississippi","initials":"m","adjacent":["AL","TN","AR","LA"]},"MO":{"name":"Missouri","initials":"m","adjacent":["AR","TN","KY","IL","IA","NE","KS","OK"]},"MT":{"name":"Montana","initials":"m","adjacent":["ID","WY","SD","ND"]},"NE":{"name":"Nebraska","initials":"n","adjacent":["KS","MO","IA","SD","WY","CO"]},"NV":{"name":"Nevada","initials":"n","adjacent":["AZ","UT","ID","OR","CA"]},"NH":{"name":"NewHampshire","initials":"nh","adjacent":["VT","MA","ME"]},"NJ":{"name":"NewJersey","initials":"nj","adjacent":["NY","PA","DE"]},"NM":{"name":"NewMexico","initials":"nm","adjacent":["TX","OK","CO","AZ"]},"NY":{"name":"NewYork","initials":"ny","adjacent":["PA","NJ","CT","MA","VT"]},"NC":{"name":"NorthCarolina","initials":"nc","adjacent":["VA","TN","GA","SC"]},"ND":{"name":"NorthDakota","initials":"nd","adjacent":["MT","SD","MN"]},"OH":{"name":"Ohio","initials":"o","adjacent":["MI","IN","KY","WV","PA"]},"OK":{"name":"Oklahoma","initials":"o","adjacent":["TX","AR","MO","KS","CO","NM"]},"OR":{"name":"Oregon","initials":"o","adjacent":["CA","NV","ID","WA"]},"PA":{"name":"Pennsylvania","initials":"p","adjacent":["OH","WV","MD","DE","NJ","NY"]},"RI":{"name":"RhodeIsland","initials":"ri","adjacent":["MA","CT"]},"SC":{"name":"SouthCarolina","initials":"sc","adjacent":["NC","GA"]},"SD":{"name":"SouthDakota","initials":"sd","adjacent":["NE","IA","MN","ND","MT","WY"]},"TN":{"name":"Tennessee","initials":"t","adjacent":["AL","GA","NC","VA","KY","MO","AR","MS"]},"TX":{"name":"Texas","initials":"t","adjacent":["LA","AR","OK","NM"]},"UT":{"name":"Utah","initials":"u","adjacent":["AZ","CO","WY","ID","NV"]},"VT":{"name":"Vermont","initials":"v","adjacent":["NY","MA","NH"]},"VA":{"name":"Virginia","initials":"v","adjacent":["MD","WV","KY","TN","NC"]},"WA":{"name":"Washington","initials":"w","adjacent":["OR","ID"]},"WV":{"name":"WestVirginia","initials":"wv","adjacent":["VA","MD","PA","OH","KY"]},"WI":{"name":"Wisconsin","initials":"w","adjacent":["MN","IA","IL","MI"]},"WY":{"name":"Wyoming","initials":"w","adjacent":["CO","NE","SD","MT","ID","UT"]}}
diff --git a/challenge-014/feng-chang/perl5/ch-1.pl b/challenge-014/feng-chang/perl5/ch-1.pl
new file mode 100755
index 0000000000..91815b7ad5
--- /dev/null
+++ b/challenge-014/feng-chang/perl5/ch-1.pl
@@ -0,0 +1,22 @@
+#!/bin/env perl
+
+use Modern::Perl;
+
+my @eck = (0, 0);
+
+exit unless defined $ARGV[0];
+my $n = int($ARGV[0]);
+exit if $n < 2;
+
+for my $i (2 .. $n) {
+ $eck[$i] = 0;
+
+ for (my $j = $i - 2; $j >= 0; --$j) {
+ if ($eck[$j] == $eck[$i - 1]) {
+ $eck[$i] = $i - $j - 1;
+ last;
+ }
+ }
+}
+
+say join(' ', @eck);
diff --git a/challenge-014/feng-chang/perl5/ch-2.pl b/challenge-014/feng-chang/perl5/ch-2.pl
new file mode 100755
index 0000000000..74159cb8e0
--- /dev/null
+++ b/challenge-014/feng-chang/perl5/ch-2.pl
@@ -0,0 +1,40 @@
+#!/bin/env perl
+
+use Modern::Perl;
+
+my @aUSPS = qw(
+ al ak az ar ca co ct de fl ga
+ hi id il in ia ks ky la me md
+ ma mi mn ms mo mt ne nv nh nj
+ nm ny nc nd oh ok or pa ri sc
+ sd tn tx ut vt va wa wv wi wy
+);
+
+my %hUSPS;
+map { $hUSPS{ $_ } = 1 } @aUSPS;
+
+my @words;
+my $max_len = 0;
+
+open my $fh, '<', '/usr/share/dict/words' or die "cannot read /usr/share/dict/words\n";
+
+myloop:
+while (my $w = <$fh>) {
+ chomp $w;
+ $w = lc($w);
+
+ for my $p ($w =~ m/..?/g) {
+ next myloop unless $hUSPS{ $p };
+ }
+
+ push @words, $w;
+ my $len = length $w;
+ $max_len = $len if $len > $max_len;
+}
+close $fh;
+
+say "max word length is $max_len";
+
+for my $w (@words) {
+ say $w if length($w) == $max_len;
+}
diff --git a/challenge-014/feng-chang/perl6/ch-1.p6 b/challenge-014/feng-chang/perl6/ch-1.p6
new file mode 100755
index 0000000000..7fe81fe8ea
--- /dev/null
+++ b/challenge-014/feng-chang/perl6/ch-1.p6
@@ -0,0 +1,18 @@
+#!/bin/env perl6
+
+sub MAIN(UInt $n) {
+ my @eck = 0, 0;
+
+ for 2..$n -> Int $i {
+ @eck[$i] = 0;
+
+ for $i - 2 ... 0 -> Int $j {
+ if @eck[$j] == @eck[$i - 1] {
+ @eck[$i] = $i - $j - 1;
+ last;
+ }
+ }
+ }
+
+ say @eck;
+}
diff --git a/challenge-014/feng-chang/perl6/ch-2.p6 b/challenge-014/feng-chang/perl6/ch-2.p6
new file mode 100755
index 0000000000..5c11db745a
--- /dev/null
+++ b/challenge-014/feng-chang/perl6/ch-2.p6
@@ -0,0 +1,17 @@
+#!/bin/env perl6
+
+my @usps = <
+ al ak az ar ca co ct de fl ga
+ hi id il in ia ks ky la me md
+ ma mi mn ms mo mt ne nv nh nj
+ nm ny nc nd oh ok or pa ri sc
+ sd tn tx ut vt va wa wv wi wy
+>;
+
+my @words = '/usr/share/dict/words'.IO.lines».lc.grep({ all($_.comb(2)) ∈ @usps }).unique;
+
+my Int $max-length = @words».chars.max;
+say "max word length is $max-length";
+
+my @longest-words = @words.grep: { $_.chars == $max-length };
+say @longest-words;
diff --git a/challenge-014/gustavo-chaves/perl5/README.pod b/challenge-014/gustavo-chaves/perl5/README.pod
index 3eb671d407..b01ac3c1f9 100644
--- a/challenge-014/gustavo-chaves/perl5/README.pod
+++ b/challenge-014/gustavo-chaves/perl5/README.pod
@@ -19,7 +19,7 @@ The recursive solution is a little easier to grasp, I think, because it's a more
direct expression of the sequence's definition. But even using memoization it's
33 times slower than the iterative version.
- $ ./ch-1a.pl 10
+ $ ./ch-1-recursive.pl 10
0
0
1
@@ -31,7 +31,7 @@ direct expression of the sequence's definition. But even using memoization it's
1
6
- $ ./ch-1b.pl 10
+ $ ./ch-1-iterative.pl 10
0
0
1
@@ -60,8 +60,44 @@ the US Postal Codes.
But I was dumbfounded when I ran it and saw the result:
- $ ./ch-2.pl
+ $ ./ch-2-one.pl
Campinas
Campinas is the name of the city where I live, in Brazil. But I don't have a
clue what is it doing in an English dictionary! :-)
+
+After having sent my solutions it downed on me that there could be more than one
+"largest" word in the dictionary. So, I implemented a second version which
+prints all of them:
+
+ $ ./ch-2-all.pl
+ Campinas
+ Concorde
+ Ganymede
+ Mandarin
+ Victoria
+ calamine
+ complain
+ mainland
+ malarial
+ mandarin
+ mascaras
+ memorial
+ moorland
+
+=head1 #extra US Traversal
+
+Neil Bowers blogged about this challenge saying that the second problem wasn't
+exactly the one he proposed. He explained what he actually had in mind in a
+L<blog post|http://neilb.org/2019/06/24/additional-challenge-14.html>.
+
+Basically, he wants to know what is the largest English word that can be made
+using only the initials if US states, beginning in any of them and following
+only adjacent states. He offered a JSON data structure in a GitHub Gist
+containing the ajdacency and initials of the states.
+
+Using the Linux dictionary in F</usr/share/dict/words> my script tells me that
+the word is "fatal":
+
+ $ ./ch-extra.pl
+ fatal (Florida => Alabama => Tennessee => Arkansas => Louisiana)
diff --git a/challenge-014/gustavo-chaves/perl5/ch-1a.pl b/challenge-014/gustavo-chaves/perl5/ch-1-recursive.pl
index 3b24e8a570..98002f0cad 100755
--- a/challenge-014/gustavo-chaves/perl5/ch-1a.pl
+++ b/challenge-014/gustavo-chaves/perl5/ch-1-recursive.pl
@@ -5,26 +5,32 @@
# (https://en.wikipedia.org/wiki/Van_Eck%27s_sequence). This challenge was
# proposed by team member Andrezgz.
-# This is an iterative implementation, which is more than 30x faster than the
-# recursive one.
+# This is a recursive implementation.
use 5.026;
use strict;
use warnings;
+use Memoize;
my $sequence_size = shift or die "Usage: $0 SIZE\n";
-my @sequence = (0);
+memoize('van_ecks');
+sub van_ecks {
+ my ($n) = @_;
-VALUE:
-for my $i (0 .. $sequence_size-2) {
- for (my $j=$i-1; $j >= 0; --$j) {
- if ($sequence[$j] == $sequence[$i]) {
- push @sequence, $i-$j;
- next VALUE;
+ return 0 if $n <= 1;
+
+ my $previous_value = van_ecks($n-1);
+
+ for (my $i=$n-2; $i >= 0; --$i) {
+ if (van_ecks($i) == $previous_value) {
+ return ($n-1) - $i;
}
}
- push @sequence, 0;
+
+ return 0;
}
-say foreach @sequence;
+for my $i (0 .. $sequence_size-1) {
+ say van_ecks($i);
+}
diff --git a/challenge-014/gustavo-chaves/perl5/ch-1.pl b/challenge-014/gustavo-chaves/perl5/ch-1.pl
index 98002f0cad..3b24e8a570 100755
--- a/challenge-014/gustavo-chaves/perl5/ch-1.pl
+++ b/challenge-014/gustavo-chaves/perl5/ch-1.pl
@@ -5,32 +5,26 @@
# (https://en.wikipedia.org/wiki/Van_Eck%27s_sequence). This challenge was
# proposed by team member Andrezgz.
-# This is a recursive implementation.
+# This is an iterative implementation, which is more than 30x faster than the
+# recursive one.
use 5.026;
use strict;
use warnings;
-use Memoize;
my $sequence_size = shift or die "Usage: $0 SIZE\n";
-memoize('van_ecks');
-sub van_ecks {
- my ($n) = @_;
+my @sequence = (0);
- return 0 if $n <= 1;
-
- my $previous_value = van_ecks($n-1);
-
- for (my $i=$n-2; $i >= 0; --$i) {
- if (van_ecks($i) == $previous_value) {
- return ($n-1) - $i;
+VALUE:
+for my $i (0 .. $sequence_size-2) {
+ for (my $j=$i-1; $j >= 0; --$j) {
+ if ($sequence[$j] == $sequence[$i]) {
+ push @sequence, $i-$j;
+ next VALUE;
}
}
-
- return 0;
+ push @sequence, 0;
}
-for my $i (0 .. $sequence_size-1) {
- say van_ecks($i);
-}
+say foreach @sequence;
diff --git a/challenge-014/gustavo-chaves/perl5/ch-2-all.pl b/challenge-014/gustavo-chaves/perl5/ch-2-all.pl
new file mode 100755
index 0000000000..726576f4a3
--- /dev/null
+++ b/challenge-014/gustavo-chaves/perl5/ch-2-all.pl
@@ -0,0 +1,40 @@
+#!/usr/bin/env perl
+
+# Using only the official postal (2-letter) abbreviations for the 50
+# U.S. states, write a script to find the longest English word you can spell?
+# Here is the list of U.S. states abbreviations as per wikipedia page
+# (https://en.wikipedia.org/wiki/List_of_U.S._state_abbreviations). This
+# challenge was proposed by team member Neil Bowers.
+
+# This version prints all the largest words.
+
+use 5.026;
+use strict;
+use autodie;
+use warnings;
+use Locale::US;
+use List::Util qw(all);
+
+my @postal_codes = Locale::US->new()->all_state_codes();
+my %postal_codes = map {lc($_) => undef} @postal_codes;
+
+my $largest_length_so_far = 0;
+my @largest_words_so_far;
+
+open my $dict, '<', '/usr/share/dict/words';
+while (<$dict>) {
+ chomp;
+ my $word = $_;
+ next unless length($word) >= $largest_length_so_far;
+ next unless (length($word) % 2) == 0;
+ next unless all {exists $postal_codes{$_}} (lc($word) =~ m/../g);
+ if (length($word) == $largest_length_so_far) {
+ push @largest_words_so_far, $word;
+ } else {
+ $largest_length_so_far = length($word);
+ @largest_words_so_far = ($word);
+ }
+}
+close $dict;
+
+say foreach @largest_words_so_far;
diff --git a/challenge-014/gustavo-chaves/perl5/ch-2.pl b/challenge-014/gustavo-chaves/perl5/ch-2.pl
index 66a3bc60bd..1ef5e6c00e 100755
--- a/challenge-014/gustavo-chaves/perl5/ch-2.pl
+++ b/challenge-014/gustavo-chaves/perl5/ch-2.pl
@@ -6,6 +6,8 @@
# (https://en.wikipedia.org/wiki/List_of_U.S._state_abbreviations). This
# challenge was proposed by team member Neil Bowers.
+# This version prints the first largest word.
+
use 5.026;
use strict;
use autodie;
diff --git a/challenge-014/gustavo-chaves/perl5/ch-extra.pl b/challenge-014/gustavo-chaves/perl5/ch-extra.pl
new file mode 100755
index 0000000000..c5f21c3e25
--- /dev/null
+++ b/challenge-014/gustavo-chaves/perl5/ch-extra.pl
@@ -0,0 +1,63 @@
+#!/usr/bin/env perl
+
+# http://neilb.org/2019/06/24/additional-challenge-14.html
+
+use 5.026;
+use strict;
+use autodie;
+use warnings;
+use LWP::Simple;
+use JSON;
+
+my $usa_state_data_url = 'https://gist.githubusercontent.com/neilb/ee60cd179d5eb17d1cb616cdeeda760f/raw/3d31a508a5277ddb4df3a73fb14715102b452302/usa-state-data.json';
+
+my $usa_state_data_json = get($usa_state_data_url)
+ or die "Could not get $usa_state_data_url";
+
+my $usa_state_data = decode_json($usa_state_data_json);
+
+my @all_states = sort keys %$usa_state_data;
+
+# Mark all states are non-visited yet.
+$_->{visited} = 0 foreach values %$usa_state_data;
+
+sub is_traversable_via {
+ my ($word, $adjacents) = @_;
+
+ foreach my $state (@{$usa_state_data}{@$adjacents}) {
+ next if $state->{visited};
+ my $initials = $state->{initials};
+ next if $initials ne substr($word, 0, length($initials));
+ return ($state) if length($initials) eq length($word);
+ local $state->{visited} = 1;
+ if (my @path = is_traversable_via(substr($word, length($initials)), $state->{adjacent})) {
+ return ($state, @path);
+ }
+ }
+
+ return;
+}
+
+my $largest_length_so_far = 0;
+my @largest_words_so_far;
+
+open my $dict, '<', '/usr/share/dict/words';
+while (<$dict>) {
+ chomp;
+ my $word = $_;
+ next unless length($word) >= $largest_length_so_far;
+ if (my @path = is_traversable_via(lc $word, \@all_states)) {
+ if (length($word) == $largest_length_so_far) {
+ push @largest_words_so_far, [$word, \@path];
+ } else {
+ $largest_length_so_far = length($word);
+ @largest_words_so_far = ([$word, \@path]);
+ }
+ }
+}
+close $dict;
+
+foreach (@largest_words_so_far) {
+ my ($word, $path) = @$_;
+ say $word, ' (', join(' => ', map {$_->{name}} @$path), ')';
+}
diff --git a/challenge-014/jaime/README b/challenge-014/jaime/README
index 6b98f9b732..9acbfee5ea 100644
--- a/challenge-014/jaime/README
+++ b/challenge-014/jaime/README
@@ -2,41 +2,14 @@ Solution by Jaime Corchado, (@tortsnare)[https://twitter.com/tortsnare].
# Challenge #1
-The numbers formed by adding one to the products of the smallest
-primes are called the Euclid Numbers (see wiki). Write a script that
-finds the smallest Euclid Number that is not prime.
-
-## Solution
-
-Calculate the product of prime numbers and check if each successor is a prime.
+Write a script to generate Van Eck’s sequence.
# Challenge #2
-Write a script that finds the common directory path, given a
-collection of paths and directory separator. For example, if the
-following paths are supplied.
-
-```
-/a/b/c/d
-/a/b/cd
-/a/b/cc
-/a/b/c/d/e
-```
-
-and the path separator is `/`. Your script should return `/a/b` as common
-directory path.
-
-## Solution
-
-```
-perl -- ch-2.pl <*delimiter*> <*list of strings*>
-```
-
-The path *delimiter* is a string like `/`.
-The *list of strings* is a string like `/usr/bin:/usr/sbin`.
-
-The solution is to find the consecutive intersection of all paths.
+Using only the official postal (2-letter) abbreviations for the 50 U.S. states,
+write a script to find the longest English word you can spell.
# Challenge #3
-Find out the synonyms of a given word using the Synonyms API.
+Find the given city current time using the Geo DB Cities API.
+
diff --git a/challenge-014/jaime/perl5/ch-1.pl b/challenge-014/jaime/perl5/ch-1.pl
new file mode 100644
index 0000000000..18041efa05
--- /dev/null
+++ b/challenge-014/jaime/perl5/ch-1.pl
@@ -0,0 +1,26 @@
+# Solution by Jaime Corchado, (@tortsnare)[https://twitter.com/tortsnare].
+#
+# Challenge #1
+#
+# Write a script to generate Van Eck’s sequence.
+
+my @ecks = (0);
+print "0\n"; # start the sequence.
+
+for (my $n = 0; ; $n++) {
+ $a1 = 0;
+ $an = shift @ecks;
+
+ my $m = 1; # the distance between matching entries.
+ for my $am (@ecks) {
+ if ($an == $am) {
+ $a1 = $m;
+ last; # only update with most recent entry.
+ }
+ } continue { $m++; }
+
+ unshift @ecks, $an;
+ unshift @ecks, $a1; # series is stored in reverse.
+
+ print "@ecks[0]\n"; # filter series with `perl ch-1.pl | head -n $LENGTH`
+}
diff --git a/challenge-014/jaime/perl5/ch-2.pl b/challenge-014/jaime/perl5/ch-2.pl
new file mode 100644
index 0000000000..d8dcd24d7e
--- /dev/null
+++ b/challenge-014/jaime/perl5/ch-2.pl
@@ -0,0 +1,20 @@
+# Solution by Jaime Corchado, (@tortsnare)[https://twitter.com/tortsnare].
+#
+# Challenge #2
+#
+# Using only the official postal abbreviations for the 50 U.S. states,
+# write a script to find the longest English word you can spell.
+
+# list of english words of even length, minus majuscule and hyphenated.
+my @words = ("aa", "aardvark", "aardwolf", "abac", "abacay", "abaction", "abaculus", "abacus", "abaissed", "abalienate", "abalienation", "abampere", "abaptiston", "abarticulation", "abas", "abased", "abasedly", "abasedness", "abaser", "abasia", "abasic", "abatable", "abater", "abatis", "abatised", "abaton", "abator", "abattoir", "abbacy", "abbasi", "abbatial", "abbess", "abbeystede", "abbotnullius", "abbreviate", "abbreviately", "abbreviation", "abbreviatory", "abbreviature", "abdest", "abdicant", "abdicate", "abdication", "abdicative", "abditive", "abditory", "abdominalian", "abdominoanterior", "abdominocentesis", "abdominocystic", "abdominohysterectomy", "abdominothoracic", "abdominous", "abduce", "abducens", "abducent", "abduct", "abductor", "abed", "abeigh", "abelmosk", "abeltree", "aberdevine", "aberrant", "aberrate", "aberration", "aberrational", "abet", "abetment", "abevacuation", "abey", "abeyance", "abeyancy", "abhiseka", "abhorrence", "abhorrency", "abhorrer", "abhorrible", "abidal", "abidance", "abider", "abietate", "abietene", "abilao", "abilla", "abiogenesist", "abiogenist", "abiogenous", "abiogeny", "abiology", "abiotrophy", "abir", "abirritant", "abirritate", "abirritation", "abirritative", "abject", "abjectedness", "abjectly", "abjectness", "abjudicate", "abjudication", "abjunction", "abjunctive", "abjuration", "abjuratory", "abjure", "abjurement", "abkari", "ablach", "ablare", "ablastemic", "ablate", "ablation", "ablative", "ablaut", "ablaze", "able", "ablegate", "ableness", "ablepharia", "ablepharon", "ablepsia", "ableptical", "ableptically", "ablest", "ablewhackets", "ablins", "abloom", "ablude", "ablush", "ablution", "abluvion", "ably", "abnegate", "abnegation", "abnegative", "abnerval", "abneural", "abnormal", "abnormally", "abnormalness", "aboard", "abolitionary", "abolitionism", "abolitionist", "abolitionize", "abolla", "abomasum", "abomasus", "abominable", "abominableness", "abominably", "abominator", "aborad", "aboral", "aborally", "aboriginal", "aboriginally", "aborticide", "abortion", "abortional", "abortive", "abortively", "abortiveness", "abound", "abounder", "abouts", "aboveboard", "aboveproof", "abox", "abrachia", "abradant", "abrade", "abraid", "abranchial", "abranchian", "abrase", "abrash", "abrasiometer", "abrasion", "abrasive", "abrastol", "abraum", "abreaction", "abrenounce", "abrico", "abridged", "abridgedly", "abridger", "abridgment", "abristle", "abroad", "abrocome", "abrogate", "abrogation", "abrogative", "abrook", "abrotine", "abrupt", "abruptedly", "abruptly", "abruptness", "absarokite", "abscession", "abscissa", "abscisse", "abscission", "absconce", "absconsa", "abscoulomb", "absent", "absentee", "absenteeship", "absenter", "absently", "absentment", "absentmindedly", "absentness", "absfarad", "abshenry", "absinthe", "absinthial", "absinthian", "absinthine", "absinthism", "absinthismic", "absinthium", "absmho", "absohm", "absolute", "absolutely", "absoluteness", "absolution", "absolutism", "absolutist", "absolutistic", "absolutistically", "absolutive", "absolutization", "absolutize", "absolutory", "absolvable", "absolver", "absolvitor", "absonant", "absonous", "absorb", "absorbable", "absorbed", "absorbedly", "absorbedness", "absorbefacient", "absorbency", "absorber", "absorptiometer", "absorption", "absorptive", "absorptively", "absorptiveness", "absorptivity", "absquatulate", "abstemious", "abstemiously", "abstemiousness", "abstention", "absterge", "abstergent", "abstersion", "abstersive", "abstersiveness", "abstinence", "abstinency", "abstinential", "abstract", "abstracted", "abstractedly", "abstractedness", "abstracter", "abstractionism", "abstractionist", "abstractitious", "abstractly", "abstractness", "abstractor", "abstrahent", "abstricted", "abstruse", "abstrusely", "abstruseness", "abstrusion", "abstrusity", "absume", "absumption", "absurd", "absurdly", "absurdness", "abterminal", "abthainrie", "abucco", "abulia", "abulic", "abulomania", "abundant", "abundantly", "aburst", "abusable", "abusedly", "abusee", "abuseful", "abusefully", "abusefulness", "abuser", "abusious", "abut", "abutment", "abutting", "abvolt", "abyssolith", "acacetin", "acacin", "academic", "academical", "academically", "acadialite", "acajou", "acalephoid", "acalycal", "acampsia", "acanaceous", "acanonical", "acanth", "acanthaceous", "acanthad", "acanthin", "acanthocarpous", "acanthocephalous", "acanthocladous", "acanthological", "acantholysis", "acanthon", "acanthophorous", "acanthopod", "acanthopterous", "acanthopterygian", "acanthosis", "acanthus", "acapnial", "acapulco", "acardiac", "acaricidal", "acarid", "acarinosis", "acarol", "acarophilous", "acarotoxic", "acarpelous", "acarpous", "acatalepsy", "acatallactic", "acataposis", "acategorical", "acatharsia", "acaudate", "acauline", "acaulose", "acaulous", "acca", "accede", "accelerant", "accelerate", "acceleration", "accelerative", "acceleratory", "accend", "accendible", "accensor", "accent", "accentless", "accentor", "accentuality", "accentuate", "accentuation", "accentus", "accept", "acceptable", "acceptableness", "acceptably", "acceptance", "acceptancy", "accepted", "acceptedly", "accepter", "acceptor", "acceptress", "accersitor", "access", "accessible", "accessibly", "accessless", "accident", "accidental", "accidentally", "accidentalness", "accidented", "accidentiality", "accidently", "accipitral", "accismus", "accite", "acclamator", "acclimatable", "acclimatizable", "acclimatizer", "acclinal", "accloy", "accoil", "accolade", "accolent", "accommodable", "accommodableness", "accommodator", "accompanyist", "accompletive", "accomplice", "accompliceship", "accomplicity", "accomplish", "accomplishable", "accomplished", "accomplisher", "accomplishment", "accord", "accordable", "accordance", "accordancy", "accorder", "accordionist", "accost", "accostable", "accosted", "accouche", "accouchement", "accoucheur", "accountability", "accountant", "accountantship", "accounting", "accouple", "accouplement", "accouter", "accouterment", "accredit", "accredited", "accreditment", "accrementitial", "accrementition", "accresce", "accrescent", "accretal", "accretionary", "accroach", "accrue", "accruement", "accubation", "accultural", "accumbency", "accumber", "accumulate", "accumulation", "accumulative", "accumulatively", "accumulativeness", "accuracy", "accurate", "accurately", "accurateness", "accursed", "accursedly", "accursedness", "accusant", "accusation", "accusative", "accusatively", "accusatorial", "accusatorially", "accusatory", "accusatrix", "accuse", "accusingly", "accusive", "accustom", "accustomed", "accustomedly", "accustomedness", "aceanthrenequinone", "acecaffine", "aceconitic", "acedia", "acediamine", "acediast", "acenaphthene", "acenaphthylene", "acentric", "aceology", "acephaline", "acephalism", "acephalist", "acephalocyst", "acephalous", "aceraceous", "acerathere", "aceratosis", "acerbate", "acerbity", "acerin", "acerra", "acertannin", "acervate", "acervately", "acervation", "acervative", "acervose", "acervuline", "acescent", "acetabular", "acetabulum", "acetacetic", "acetal", "acetaldehydase", "acetaldehyde", "acetamidin", "acetaminol", "acetanilid", "acetarious", "acetarsone", "acetated", "acetenyl", "acetic", "acetimeter", "acetimetry", "acetin", "acetoacetanilide", "acetoacetate", "acetoamidophenol", "acetobenzoic", "acetobromanilide", "acetochloral", "acetocinnamene", "acetol", "acetolysis", "acetolytic", "acetometer", "acetometry", "acetonaphthone", "acetonemia", "acetonemic", "acetonic", "acetonitrile", "acetonuria", "acetonurometer", "acetonyl", "acetophenetide", "acetophenine", "acetophenone", "acetopyrin", "acetosalicylic", "acetosoluble", "acetotoluide", "acetotoluidine", "acetoveratrone", "acetoxyl", "acetoxyphthalide", "acetphenetid", "acetphenetidin", "acetract", "acetum", "aceturic", "acetyl", "acetylacetonates", "acetylator", "acetylbenzoate", "acetylbiuret", "acetylenediurein", "acetylenic", "acetylenyl", "acetylfluoride", "acetylic", "acetyliodide", "acetylizable", "acetylizer", "acetylmethylcarbinol", "acetylperoxide", "acetylphenol", "acetylrosaniline", "acetylsalicylate", "acetyltannin", "acetylthymol", "acetyltropeine", "acetylurea", "achage", "achate", "ache", "acheilia", "acheiria", "acheirus", "achene", "achenial", "achenium", "achenocarp", "achenodium", "achete", "acheweed", "achievable", "achiever", "achilary", "achill", "achilleine", "achillodynia", "achime", "aching", "achingly", "achira", "achlamydeous", "achlorhydria", "acholous", "achondrite", "achondroplasia", "achordal", "achree", "achroacyte", "achrodextrin", "achroiocythaemia", "achroite", "achromasia", "achromat", "achromatic", "achromatically", "achromatin", "achromatinic", "achromatizable", "achromatolysis", "achromatophile", "achromatopia", "achromatopsy", "achromatosis", "achromaturia", "achromia", "achromic", "achromoderma", "achromophilous", "achromotrichia", "achronical", "achroodextrinase", "achroous", "achtel", "achtelthaler", "achy", "achylous", "achymous", "acicular", "acicularly", "aciculated", "aciculum", "acid", "acidemia", "acider", "acidic", "acidifiant", "acidific", "acidimeter", "acidimetry", "acidly", "acidness", "acidometer", "acidometry", "acidophile", "acidophilous", "acidoproteolytic", "acidosis", "acidosteophyte", "acidotic", "aciduric", "acidyl", "acierage", "acierate", "acieration", "aciliate", "acinaceous", "acinaces", "acinacifolious", "acinar", "acinarious", "acinetan", "acinetic", "acinetinan", "acinic", "acinotubular", "acinus", "acipenserine", "acipenseroid", "ackman", "acknow", "acknowledged", "acknowledgedly", "acknowledger", "aclastic", "acle", "acleistous", "aclidian", "acloud", "acme", "acmite", "acne", "acneform", "acnode", "acocantherin", "acoelomate", "acoelomatous", "acoelomous", "acoelous", "acoine", "acologic", "acolythate", "acomia", "acondylose", "acondylous", "aconic", "aconin", "aconital", "aconitia", "aconitic", "aconitin", "acontium", "aconuresis", "acopic", "acopon", "acopyrin", "acor", "acorea", "acoria", "acosmism", "acosmist", "acosmistic", "acotyledon", "acouometer", "acoupa", "acousmatic", "acoustic", "acoustical", "acoustically", "acousticolateral", "acquaint", "acquaintance", "acquaintanceship", "acquaintancy", "acquainted", "acquaintedness", "acquiescence", "acquiescency", "acquiescer", "acquirable", "acquired", "acquirenda", "acquirer", "acquisible", "acquisited", "acquisitor", "acquisitum", "acquit", "acquitment", "acracy", "acranial", "acrawl", "acraze", "acre", "acreable", "acreak", "acream", "acridian", "acridine", "acridinium", "acridity", "acridone", "acridonium", "acridophagus", "acriflavin", "acrimony", "acrite", "acroamatic", "acroanesthesia", "acroasphyxia", "acroataxia", "acroatic", "acrobacy", "acrobatics", "acrobatism", "acrobryous", "acrobystitis", "acrocephalia", "acrocephalic", "acroconidium", "acrocoracoid", "acrocyanosis", "acrocyst", "acrodactylum", "acrodermatitis", "acrodont", "acroesthesia", "acrogamous", "acrogamy", "acrogenous", "acrogenously", "acrography", "acrogynous", "acrolein", "acrolith", "acrolithan", "acrolithic", "acrologism", "acrology", "acromastitis", "acromegaly", "acromelalgia", "acromial", "acromicria", "acromiodeltoid", "acromiohumeral", "acromiohyoid", "acromion", "acromiosternal", "acromyodic", "acromyotonia", "acromyotonus", "acronarcotic", "acroneurosis", "acronych", "acronymize", "acronymous", "acrook", "acrophobia", "acrophonetic", "acrophonic", "acropodium", "acropoleis", "acrorhagus", "acrosarc", "acrosarcum", "acroscleriasis", "acroscopic", "acrose", "acrosome", "across", "acrostic", "acrostical", "acrostically", "acrostichoid", "acroteleutic", "acroterial", "acroterium", "acrotism", "acrotomous", "acrotrophoneurosis", "acrylate", "acta", "actability", "actification", "actifier", "actify", "actinautographic", "actine", "actinenchyma", "acting", "act