aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-111/abigail/README.md120
-rw-r--r--challenge-111/abigail/awk/ch-1.awk30
-rw-r--r--challenge-111/abigail/awk/ch-2.gawk33
-rw-r--r--challenge-111/abigail/bash/ch-1.sh29
-rw-r--r--challenge-111/abigail/bash/ch-2.sh30
-rw-r--r--challenge-111/abigail/c/ch-1.c49
-rw-r--r--challenge-111/abigail/c/ch-2.c60
-rw-r--r--challenge-111/abigail/lua/ch-1.lua33
-rw-r--r--challenge-111/abigail/lua/ch-2.lua25
-rw-r--r--challenge-111/abigail/node/ch-1.js37
-rw-r--r--challenge-111/abigail/node/ch-2.js23
-rw-r--r--challenge-111/abigail/perl/ch-1.pl50
-rw-r--r--challenge-111/abigail/perl/ch-2.pl57
-rw-r--r--challenge-111/abigail/python/ch-1.py31
-rw-r--r--challenge-111/abigail/python/ch-2.py35
-rw-r--r--challenge-111/abigail/ruby/ch-1.rb32
-rw-r--r--challenge-111/abigail/ruby/ch-2.rb34
-rw-r--r--challenge-111/abigail/t/ctest.ini21
-rw-r--r--challenge-111/abigail/t/input-1-17
-rw-r--r--challenge-111/abigail/t/input-1-27
-rw-r--r--challenge-111/abigail/t/input-1-310
-rw-r--r--challenge-111/abigail/t/input-2-10
-rw-r--r--challenge-111/abigail/t/input-2-20
-rw-r--r--challenge-111/abigail/t/input-2-30
-rw-r--r--challenge-111/abigail/t/output-1-1.exp2
-rw-r--r--challenge-111/abigail/t/output-1-2.exp2
-rw-r--r--challenge-111/abigail/t/output-1-3.exp5
-rw-r--r--challenge-111/abigail/t/output-2-1.exp1
-rw-r--r--challenge-111/abigail/t/output-2-2.exp1
-rw-r--r--challenge-111/abigail/t/output-2-3.exp1
30 files changed, 705 insertions, 60 deletions
diff --git a/challenge-111/abigail/README.md b/challenge-111/abigail/README.md
index f73efb55cd..b9e45903c7 100644
--- a/challenge-111/abigail/README.md
+++ b/challenge-111/abigail/README.md
@@ -1,44 +1,34 @@
-# Solutions by Asbigail
-## [Valid Phone Number Formats](https://perlweeklychallenge.org/blog/perl-weekly-challenge-110/#TASK1)
-
-> You are given a text file.
->
-> Write a script to display all valid phone numbers in the given text file.
-
-### Acceptable Phone Number Formats
-
-~~~~
-+nn nnnnnnnnnn
-(nn) nnnnnnnnnn
-nnnn nnnnnnnnnn
-~~~~
-
-### Input File
-~~~~
-0044 1148820341
- +44 1148820341
- 44-11-4882-0341
-(44) 1148820341
- 00 1148820341
-~~~~
-
-### Output
-~~~~
-0044 1148820341
- +44 1148820341
-(44) 1148820341
-~~~~
+# Solutions by Abigail
+## [Search Matrix](https://perlweeklychallenge.org/blog/perl-weekly-challenge-111/#TASK1)
-### Notes
-The examples show we should not take the specification as a specification;
-just a rough guideline. According to the specification,
-" +44 1148820341" fails the criteria not once, but twice: it contains
-a leading space (not allowed in the specification), and it has only a
-single space between the '+44' part and the rest, where the specification
-requires two.
+> You are given 5x5 matrix filled with integers such that each row is
+> sorted from left to right and the first integer of each row is greater
+> than the last integer of the previous row.
+>
+> Write a script to find a given integer in the matrix using an
+> efficient search algorithm.
-We therefore conclude the examples just contain random spaces, and we
-can completly ignore any white space in the input.
+### Notes
+This challenge confuses me. We're basically asked to find a number
+in a sorted list. Which in languages without hashes one would solve
+with binary search (yielding an O (log N) solution), and in languages
+with hashes you'd use a hash (yielding an O (1) (expected) time solution).
+Sure, the hash takes linear preprocessing time, but since we're asked
+to write a script, we're spending linear time reading in the data
+anyway.
+
+Perhaps the intend was a subroutine which takes a matrix and a target
+number, but that was not what is being asked. The challenge explicitly
+asks for *a script*, which means we have to spend a linear amount of
+time reading data anyway. So, that's what you get.
+
+The only part where we use the fact we are given a matrix is for the
+input: the first five lines are assumed to contain the matrix. The
+rest of the input is taken as numbers to search for.
+
+Only for language lacking hashes/maps/dictionaries/tables, we will
+make use of the fact the input is sorted. For the majority of
+languages, the fact input is sorted does not offer additional benefits.
### Solutions
* [AWK](awk/ch-1.awk)
@@ -51,33 +41,44 @@ can completly ignore any white space in the input.
* [Ruby](ruby/ch-1.rb)
### Blog
-[Perl Weekly Challenge 110: Valid Phone Numbers](https://abigail.github.io/HTML/Perl-Weekly-Challenge/week-110-1.html)
-## [Transpose File](https://perlweeklychallenge.org/blog/perl-weekly-challenge-110/#TASK2)
+## [Ordered Letters](https://perlweeklychallenge.org/blog/perl-weekly-challenge-111/#TASK2)
+
+> Given a word, you can sort its letters alphabetically (case insensitive).
+> For example, 'beekeeper' becomes 'beeeeekpr' and 'dictionary' becomes
+> 'acdiinorty'.
+>
+> Write a script to find the longest English words that don't change when
+> their letters are sorted.
+
+### Notes
+We will grep the words from standard input which don't change
+if they are sorted; these are the words which match the pattern
+/^a*b*c*...z*$/i. We keep track of the longest word.
+
+If course, there does not have to be a unique word. It will depend
+on the word list used to search in. For instance, three different
+word list I used give different results:
-> You are given a text file.
->
-> Write a script to transpose the contents of the given file.
+ infochimps.com /usr/share/dict/words enable.lst
+ -------------- --------------------- ----------
+ Adelops
+ aegilops
+ alloquy
+ beefily beefily
+ begorry
+ billowy billowy
+ egilops
-### Input File
-~~~~
-name,age,sex
-Mohammad,45,m
-Joe,20,m
-Julie,35,f
-Cristina,10,f
-~~~~
+Only one of them has a unique longest word.
-### Output
-~~~~
-name,Mohammad,Joe,Julie,Cristina
-age,45,20,35,10
-sex,m,m,f,f
-~~~~
+We will be reading a word list from standard input, and write
+the longest word where the letters are in alphabetical order
+to standard output. In case of ties, we print the first one found.
### Solutions
-* [AWK](awk/ch-2.awk)
+* [GNU AWK](awk/ch-2.gawk)
* [Bash](bash/ch-2.sh)
* [C](c/ch-2.c)
* [Lua](lua/ch-2.lua)
@@ -87,5 +88,4 @@ sex,m,m,f,f
* [Ruby](ruby/ch-2.rb)
### Blog
-[Perl Weekly Challenge 110: Transpose File](https://abigail.github.io/HTML/Perl-Weekly-Challenge/week-110-2.html)
diff --git a/challenge-111/abigail/awk/ch-1.awk b/challenge-111/abigail/awk/ch-1.awk
new file mode 100644
index 0000000000..c82c027708
--- /dev/null
+++ b/challenge-111/abigail/awk/ch-1.awk
@@ -0,0 +1,30 @@
+#!/usr/bin/awk
+
+#
+# See ../README.md
+#
+
+#
+# Run as: awk -f ch-1.awk < input-file
+#
+
+BEGIN {
+ MATRIX_SIZE = 5
+}
+
+#
+# Read in the matrix first
+#
+NR <= MATRIX_SIZE {
+ for (i = 1; i <= NF; i ++) {
+ matrix [$i] = 1
+ }
+}
+
+#
+# For the rest, print 1/0 depending on whether the input
+# is in the matrix or not.
+#
+NR > MATRIX_SIZE {
+ print (matrix [$0] ? 1 : 0)
+}
diff --git a/challenge-111/abigail/awk/ch-2.gawk b/challenge-111/abigail/awk/ch-2.gawk
new file mode 100644
index 0000000000..98ac26a066
--- /dev/null
+++ b/challenge-111/abigail/awk/ch-2.gawk
@@ -0,0 +1,33 @@
+#!/usr/bin/awk
+
+#
+# See ../README.md
+#
+
+#
+# Run as: awk -f ch-2.gawk < input-file
+#
+
+BEGIN {
+ IGNORECASE = 1
+ longest = ""
+ #
+ # Create a pattern /^a*b*...z*$/
+ #
+ pat = "^"
+ for (i = 97; i <= 122; i ++) {
+ pat = pat sprintf ("%c*", i)
+ }
+ pat = pat "$"
+}
+
+#
+# Match words with letters in lexical order; keep longest.
+#
+match ($0, pat) && length ($0) > length (longest) {
+ longest = $0
+}
+
+END {
+ print longest
+}
diff --git a/challenge-111/abigail/bash/ch-1.sh b/challenge-111/abigail/bash/ch-1.sh
new file mode 100644
index 0000000000..0ef20b5732
--- /dev/null
+++ b/challenge-111/abigail/bash/ch-1.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+#
+# See ../README.md
+#
+
+#
+# Run as: bash ch-1.sh < input-file
+#
+
+declare -A matrix
+MATRIX_SIZE=5
+
+#
+# Read in the matrix
+#
+for ((i = 1; i <= $MATRIX_SIZE; i ++))
+do read -a line
+ for n in ${line[@]}
+ do matrix[$n]=1
+ done
+done
+
+#
+# Print 1/0 depending or not whether the number is in the matrix
+#
+while read number
+do echo $((matrix[$number] ? 1 : 0))
+done
diff --git a/challenge-111/abigail/bash/ch-2.sh b/challenge-111/abigail/bash/ch-2.sh
new file mode 100644
index 0000000000..7add8bc05f
--- /dev/null
+++ b/challenge-111/abigail/bash/ch-2.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+#
+# See ../README.md
+#
+
+#
+# Run as: bash ch-2.sh < input-file
+#
+
+
+set -f
+shopt -s extglob
+
+pat1="*(a)*(b)*(c)*(d)*(e)*(f)*(g)*(h)*(i)*(j)*(k)*(l)*(m)"
+pat2="*(n)*(o)*(p)*(q)*(r)*(s)*(t)*(u)*(v)*(w)*(x)*(y)*(z)"
+
+longest=""
+
+while read line
+do lower=${line,,} # Lower case input
+ left=${lower/#$pat1$pat2/} # Remove pattern
+ # Test whether nothing left,
+ # and string larger longest found
+ if [ "X$left" == "X" -a ${#line} -gt ${#longest} ]
+ then longest=$line
+ fi
+done
+
+echo $longest
diff --git a/challenge-111/abigail/c/ch-1.c b/challenge-111/abigail/c/ch-1.c
new file mode 100644
index 0000000000..a8804c7390
--- /dev/null
+++ b/challenge-111/abigail/c/ch-1.c
@@ -0,0 +1,49 @@
+# include <stdlib.h>
+# include <stdio.h>
+# include <string.h>
+
+/*
+ * See ../README.md
+ */
+
+/*
+ * Run as: cc -o ch-1.o ch-1.c; ./ch-1.o < input-file
+ */
+
+# define MATRIX_SIZE 5
+# define NR_OF_ELEMENTS (MATRIX_SIZE * MATRIX_SIZE)
+
+static int compare (const void *a, const void *b) {
+ return * (int *) a - * (int *) b;
+}
+
+int main (void) {
+ int * matrix;
+ int target;
+
+ if ((matrix = (int *) malloc (NR_OF_ELEMENTS * sizeof (int))) == NULL) {
+ perror ("Malloc failed");
+ exit (1);
+ }
+
+ /*
+ * Read in the matrix
+ */
+ for (int i = 0; i < NR_OF_ELEMENTS; i ++) {
+ if (scanf ("%d", &matrix [i]) != 1) {
+ perror ("Scanf failed");
+ exit (1);
+ }
+ }
+
+ /*
+ * Read in the search data, and print 1/0 depending on whether
+ * the read number is in the matrix or not.
+ */
+ while (scanf ("%d", &target) == 1) {
+ printf ("%d\n", bsearch (&target, matrix, NR_OF_ELEMENTS,
+ sizeof (int), compare) == NULL ? 0 : 1);
+ }
+
+ return (0);
+}
diff --git a/challenge-111/abigail/c/ch-2.c b/challenge-111/abigail/c/ch-2.c
new file mode 100644
index 0000000000..a677e4cad6
--- /dev/null
+++ b/challenge-111/abigail/c/ch-2.c
@@ -0,0 +1,60 @@
+# include <stdlib.h>
+# include <stdio.h>
+# include <string.h>
+# include <stdbool.h>
+# include <ctype.h>
+
+/*
+ * See ../README.md
+ */
+
+/*
+ * Run as: cc -o ch-2.o ch-2.c; ./ch-2.o < input-file
+ */
+
+int main (void) {
+ char * line = NULL;
+ size_t len = 0;
+ char * longest = NULL;
+ size_t longest_size = 0;
+
+ while (getline (&line, &len, stdin) != -1) {
+ /*
+ * First check whether the word has its characters
+ * in lexical order.
+ */
+ size_t i = 0;
+ bool in_order = 1;
+ while (line [i] != '\n') {
+ if ((i && tolower (line [i]) < tolower (line [i - 1])) ||
+ !isalpha (line [i])) {
+ in_order = false;
+ break;
+ }
+ i ++;
+ }
+
+ /*
+ * If we have a word with its characters in lexical order, and
+ * it's longer than the longest word found, keep the word.
+ */
+ if (in_order && i > longest_size) {
+ longest_size = i;
+ if ((longest = (char *) realloc (longest, (i + 1) * sizeof (char)))
+ == NULL) {
+ perror ("Realloc failed");
+ exit (1);
+ }
+ for (size_t j = 0; j <= i; j ++) { /* Copies the newline as well */
+ longest [j] = line [j];
+ }
+ longest [i + 1] = '\0';
+ }
+ }
+ printf ("%s", longest);
+
+ free (line);
+ free (longest);
+
+ return (0);
+}
diff --git a/challenge-111/abigail/lua/ch-1.lua b/challenge-111/abigail/lua/ch-1.lua
new file mode 100644
index 0000000000..194e55b458
--- /dev/null
+++ b/challenge-111/abigail/lua/ch-1.lua
@@ -0,0 +1,33 @@
+#!/opt/local/bin/lua
+
+--
+-- See ../README.md
+--
+
+--
+-- Run as: lua ch-1.lua < input-file
+--
+
+local MATRIX_SIZE = 5
+
+matrix = {}
+
+--
+-- Read in the matrix
+--
+for i = 1, MATRIX_SIZE * MATRIX_SIZE do
+ matrix [io . read ("*number")] = 1
+end
+
+--
+-- Read in the rest, printing 1/0 depending on
+-- whether the number is present in the matrix or not.
+--
+while true do
+ target = io . read ("*number")
+ if target == nil then break end
+ if matrix [target]
+ then print (1)
+ else print (0)
+ end
+end
diff --git a/challenge-111/abigail/lua/ch-2.lua b/challenge-111/abigail/lua/ch-2.lua
new file mode 100644
index 0000000000..6beeb6a979
--- /dev/null
+++ b/challenge-111/abigail/lua/ch-2.lua
@@ -0,0 +1,25 @@
+#!/opt/local/bin/lua
+
+--
+-- See ../README.md
+--
+
+--
+-- Run as: lua ch-2.lua < input-file
+--
+
+local longest = ""
+
+for line in io . lines () do
+ --
+ -- Find words with their letters in lexical order, and which are
+ -- longer than the longest found so far.
+ --
+ if line : lower ()
+ : find ("^a*b*c*d*e*f*g*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*$")
+ and line : len () > longest : len ()
+ then longest = line
+ end
+end
+
+print (longest)
diff --git a/challenge-111/abigail/node/ch-1.js b/challenge-111/abigail/node/ch-1.js
new file mode 100644
index 0000000000..6e97d03272
--- /dev/null
+++ b/challenge-111/abigail/node/ch-1.js
@@ -0,0 +1,37 @@
+#!/usr/local/bin/node
+
+//
+// See ../README.md
+//
+
+//
+// Run as: node ch-1.js < input-file
+//
+
+let MATRIX_SIZE = 5
+
+//
+// Read in all the numbers, both the matrix and the target numbers
+//
+let numbers =
+ require ("fs")
+. readFileSync (0) // Read all.
+. toString () // Turn it into a string.
+. match (/-?[0-9]+/g)
+
+//
+// Populate the matrix
+//
+let matrix = {}
+for (let i = 0; i < MATRIX_SIZE * MATRIX_SIZE; i ++) {
+ matrix [numbers [i]] = 1
+}
+
+//
+// Check the rest of the numbers whether they're present
+// in the matrix.
+//
+for (let j = MATRIX_SIZE * MATRIX_SIZE; j < numbers . length; j ++) {
+ console . log (matrix [numbers [j]] ? 1 : 0)
+}
+
diff --git a/challenge-111/abigail/node/ch-2.js b/challenge-111/abigail/node/ch-2.js
new file mode 100644
index 0000000000..3d7b301b5d
--- /dev/null
+++ b/challenge-111/abigail/node/ch-2.js
@@ -0,0 +1,23 @@
+#!/usr/local/bin/node
+
+//
+// See ../README.md
+//
+
+//
+// Run as: node ch-2.js < input-file
+//
+
+let longest = ""
+
+require ('readline')
+. createInterface ({input: process . stdin})
+. on ('line', _ => {
+ if (_ . match (/^a*b*c*d*e*f*g*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*$/i) &&
+ _ . length > longest . length) {
+ longest = _
+ }
+})
+. on ('close', _ => {
+ console . log (longest)
+})
diff --git a/challenge-111/abigail/perl/ch-1.pl b/challenge-111/abigail/perl/ch-1.pl
new file mode 100644
index 0000000000..00f6e2502d
--- /dev/null
+++ b/challenge-111/abigail/perl/ch-1.pl
@@ -0,0 +1,50 @@
+#!/opt/perl/bin/perl
+
+use 5.032;
+
+use strict;
+use warnings;
+no warnings 'syntax';
+
+use experimental 'signatures';
+use experimental 'lexical_subs';
+
+#
+# See ../README.md
+#
+
+#
+# Run as: perl ch-1.pl < input-file
+#
+
+#
+# This challenge confuses me. We're basically asked to find a number
+# in a sorted list. Which in languages without hashes one would solve
+# with binary search (yielding an O (log N) solution), and in languages
+# with hashes you'd use a hash (yielding an O (1) (expected) time solution).
+# Sure, the hash takes linear preprocessing time, but since we're asked
+# to write a script, we're spending linear time reading in the data
+# anyway.
+#
+# Perhaps the intend was a subroutine which takes a matrix and a target
+# number, but that was not what is being asked. The challenge explicitly
+# asks for *a script*, which means we have to spend a linear amount of
+# time reading data anyway. So, that's what you get.
+#
+# The only part where we use the fact we are given a matrix is for the
+# input: the first five lines are assumed to contain the matrix. The
+# rest of the input is taken as numbers to search for.
+#
+
+my $MATRIX_SIZE = 5;
+
+#
+# Read in a matrix of data
+#
+my %matrix;
+@matrix {<> =~ /-?[0-9]+/g} = () for 1 .. $MATRIX_SIZE;
+
+#
+# Print 0/1 depending on whether the given number is in the matrix or not.
+#
+chomp, say exists $matrix {$_} || 0 while <>
diff --git a/challenge-111/abigail/perl/ch-2.pl b/challenge-111/abigail/perl/ch-2.pl
new file mode 100644
index 0000000000..5f4041c69c
--- /dev/null
+++ b/challenge-111/abigail/perl/ch-2.pl
@@ -0,0 +1,57 @@
+#!/opt/perl/bin/perl
+
+use 5.032;
+
+use strict;
+use warnings;
+no warnings 'syntax';
+
+use experimental 'signatures';
+use experimental 'lexical_subs';
+
+#
+# See ../README.md
+#
+
+#
+# Run as: perl ch-2.pl < word-list
+#
+
+#
+# We will grep the words from standard input which don't change
+# if they are sorted; these are the words which match the pattern
+# /^a*b*c*...z*$/i. We keep track of the longest word.
+#
+# If course, there does not have to be a unique word. It will depend
+# on the word list used to search in. For instance, three different
+# word list I used give different results:
+#
+# infochimps.com /usr/share/dict/words enable.lst
+# -------------- --------------------- ----------
+# Adelops
+# aegilops
+# alloquy
+# beefily beefily
+# begorry
+# billowy billowy
+# egilops
+#
+# Only one of them has a unique longest word.
+#
+
+#
+# We will be reading a word list from standard input, and write
+# the longest word where the letters are in alphabetical order
+# to standard output. In case of ties, we print the first one found.
+#
+
+
+my $pat = join "" => map {"$_*"} 'a' .. 'z';
+
+my $longest = "";
+
+while (<>) {
+ $longest = $_ if /^$pat$/i && length ($_) > length ($longest)
+}
+
+print $longest;
diff --git a/challenge-111/abigail/python/ch-1.py b/challenge-111/abigail/python/ch-1.py
new file mode 100644
index 0000000000..ba91c8009f
--- /dev/null
+++ b/challenge-111/abigail/python/ch-1.py
@@ -0,0 +1,31 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-1.py < input-file
+#
+
+MATRIX_SIZE = 5
+
+import fileinput
+import re
+
+#
+# Read in the matrix
+#
+matrix = {}
+for i in range (MATRIX_SIZE):
+ for n in re . findall (r'-?[0-9]+', input ()):
+ matrix [n] = 1
+
+#
+# For the rest of the input, check whether it's in the matrix
+#
+for line in fileinput . input ():
+ if line . strip () in matrix:
+ print ("1")
+ else:
+ print ("0")
diff --git a/challenge-111/abigail/python/ch-2.py b/challenge-111/abigail/python/ch-2.py
new file mode 100644
index 0000000000..ce79d6b393
--- /dev/null
+++ b/challenge-111/abigail/python/ch-2.py
@@ -0,0 +1,35 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-2.py < input-file
+#
+
+import fileinput
+import string
+import re
+
+
+#
+# Create a pattern which matches words with their characters in lexical order.
+#
+pat = "^"
+for x in list (string . ascii_lowercase):
+ pat = pat + x + "*"
+pat += "$"
+
+
+#
+# Match strings with their characters in lexical order, and remember
+# the longest of them.
+#
+longest = ""
+for line in fileinput . input ():
+ line = line . strip ()
+ if re . match (pat, line . lower ()) and len (line) > len (longest):
+ longest = line
+
+print (longest)
diff --git a/challenge-111/abigail/ruby/ch-1.rb b/challenge-111/abigail/ruby/ch-1.rb
new file mode 100644
index 0000000000..ed9d9d9085
--- /dev/null
+++ b/challenge-111/abigail/ruby/ch-1.rb
@@ -0,0 +1,32 @@
+#!/usr/bin/ruby
+
+#
+# See ../README.md
+#
+
+#
+# Run as: ruby ch-1.rb < input-file
+#
+
+matrix_size = 5
+
+#
+# Read in the matrix
+#
+matrix = {}
+(1 .. matrix_size) . each do
+ ARGF . readline . scan(/-?[0-9]+/) do
+ |number|
+ matrix [number] = 1
+ end
+end
+
+
+#
+# Read in the rest of the numbers, and print 1/0 whether or
+# not they're present in the matrix.
+#
+ARGF . each_line do
+ |number|
+ puts (matrix [number . strip] ? 1 : 0)
+end
diff --git a/challenge-111/abigail/ruby/ch-2.rb b/challenge-111/abigail/ruby/ch-2.rb
new file mode 100644
index 0000000000..afe0361969
--- /dev/null
+++ b/challenge-111/abigail/ruby/ch-2.rb
@@ -0,0 +1,34 @@
+#!/usr/bin/ruby
+
+#
+# See ../README.md
+#
+
+#
+# Run as: ruby ch-2.rb < input-file
+#
+
+#
+# Create a pattern to match words with their characters in
+# lexicographical order.
+#
+pat = "^"
+("a" .. "z") . each do
+ |letter|
+ pat += letter + "*"
+end
+pat += "$"
+
+
+#
+# Find matching words, and remember the longest.
+#
+longest = ""
+ARGF . each_line do
+ |line|
+ if line . downcase =~ /#{pat}/ && line . length > longest . length
+ longest = line
+ end
+end
+
+puts (longest)
diff --git a/challenge-111/abigail/t/ctest.ini b/challenge-111/abigail/t/ctest.ini
new file mode 100644
index 0000000000..0c0dfde484
--- /dev/null
+++ b/challenge-111/abigail/t/ctest.ini
@@ -0,0 +1,21 @@
+#
+# Configuration file for running tests, using ctest.
+# See https://github.com/Abigail/Misc/blob/master/ctest
+#
+
+[names]
+1-1 = Given example
+1-2 = Use large numbers
+1-3 = Use negative numbers
+2-1 = Enable.lst
+2-2 = /usr/share/dict/words
+2-3 = infochimps.com
+
+[2-1]
+input_file = /Users/abigail/Words/enable.lst
+
+[2-2]
+input_file = /usr/share/dict/words
+
+[2-3]
+input_file = /Users/abigail/Words/infochimps.txt
diff --git a/challenge-111/abigail/t/input-1-1 b/challenge-111/abigail/t/input-1-1
new file mode 100644
index 0000000000..fa2f7e3fa1
--- /dev/null
+++ b/challenge-111/abigail/t/input-1-1
@@ -0,0 +1,7 @@
+ 1 2 3 5 7
+ 9 11 15 19 20
+23 24 25 29 31
+32 33 39 40 42
+45 47 48 49 50
+35
+39
diff --git a/challenge-111/abigail/t/input-1-2 b/challenge-111/abigail/t/input-1-2
new file mode 100644
index 0000000000..14b659ea7d
--- /dev/null
+++ b/challenge-111/abigail/t/input-1-2
@@ -0,0 +1,7 @@
+ 1000000 2000000 3000000 5000000 7000000
+ 9000000 11000000 15000000 19000000 20000000
+23000000 24000000 25000000 29000000 31000000
+32000000 33000000 39000000 40000000 42000000
+45000000 47000000 48000000 49000000 50000000
+35000000
+39000000
diff --git a/challenge-111/abigail/t/input-1-3 b/challenge-111/abigail/t/input-1-3
new file mode 100644
index 0000000000..e5dd243924
--- /dev/null
+++ b/challenge-111/abigail/t/input-1-3
@@ -0,0 +1,10 @@
+-9 -7 -5 -3 -2
+ 0 11 15 19 20
+23 24 25 29 31
+32 33 39 40 42
+45 47 48 49 50
+-5
+-1
+0
+1
+11
diff --git a/challenge-111/abigail/t/input-2-1 b/challenge-111/abigail/t/input-2-1
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/challenge-111/abigail/t/input-2-1
diff --git a/challenge-111/abigail/t/input-2-2 b/challenge-111/abigail/t/input-2-2
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/challenge-111/abigail/t/input-2-2
diff --git a/challenge-111/abigail/t/input-2-3 b/challenge-111/abigail/t/input-2-3
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/challenge-111/abigail/t/input-2-3
diff --git a/challenge-111/abigail/t/output-1-1.exp b/challenge-111/abigail/t/output-1-1.exp
new file mode 100644
index 0000000000..0d66ea1aee
--- /dev/null
+++ b/challenge-111/abigail/t/output-1-1.exp
@@ -0,0 +1,2 @@
+0
+1
diff --git a/challenge-111/abigail/t/output-1-2.exp b/challenge-111/abigail/t/output-1-2.exp
new file mode 100644
index 0000000000..0d66ea1aee
--- /dev/null
+++ b/challenge-111/abigail/t/output-1-2.exp
@@ -0,0 +1,2 @@
+0
+1
diff --git a/challenge-111/abigail/t/output-1-3.exp b/challenge-111/abigail/t/output-1-3.exp
new file mode 100644
index 0000000000..33f911e8c0
--- /dev/null
+++ b/challenge-111/abigail/t/output-1-3.exp
@@ -0,0 +1,5 @@
+1
+0
+1
+0
+1
diff --git a/challenge-111/abigail/t/output-2-1.exp b/challenge-111/abigail/t/output-2-1.exp
new file mode 100644
index 0000000000..b5029dd205
--- /dev/null
+++ b/challenge-111/abigail/t/output-2-1.exp
@@ -0,0 +1 @@
+beefily
diff --git a/challenge-111/abigail/t/output-2-2.exp b/challenge-111/abigail/t/output-2-2.exp
new file mode 100644
index 0000000000..fd3ba3ff6c
--- /dev/null
+++ b/challenge-111/abigail/t/output-2-2.exp
@@ -0,0 +1 @@
+Adelops
diff --git a/challenge-111/abigail/t/output-2-3.exp b/challenge-111/abigail/t/output-2-3.exp
new file mode 100644
index 0000000000..8dbf15984e
--- /dev/null
+++ b/