aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-05-01 01:10:18 +0100
committerGitHub <noreply@github.com>2021-05-01 01:10:18 +0100
commitc86d7cc3cf9f5b4c51d2e6fd99384729a8166418 (patch)
treea8b099562494a78a1aa82ed74c73a40205603a0c
parent111ea37f028e65705520d21e13dcb2735a33ad8a (diff)
parent8bcf6551730487cf51398a844b726d6fed93f647 (diff)
downloadperlweeklychallenge-club-c86d7cc3cf9f5b4c51d2e6fd99384729a8166418.tar.gz
perlweeklychallenge-club-c86d7cc3cf9f5b4c51d2e6fd99384729a8166418.tar.bz2
perlweeklychallenge-club-c86d7cc3cf9f5b4c51d2e6fd99384729a8166418.zip
Merge pull request #3983 from Abigail/abigail/week-110
Abigail/week 110
-rw-r--r--challenge-110/abigail/README.md124
-rw-r--r--challenge-110/abigail/awk/ch-1.awk20
-rw-r--r--challenge-110/abigail/awk/ch-2.awk31
-rw-r--r--challenge-110/abigail/bash/ch-1.sh25
-rw-r--r--challenge-110/abigail/bash/ch-2.sh30
-rw-r--r--challenge-110/abigail/c/ch-1.c79
-rw-r--r--challenge-110/abigail/c/ch-2.c83
-rw-r--r--challenge-110/abigail/lua/ch-1.lua24
-rw-r--r--challenge-110/abigail/lua/ch-2.lua32
-rw-r--r--challenge-110/abigail/node/ch-1.js21
-rw-r--r--challenge-110/abigail/node/ch-2.js29
-rw-r--r--challenge-110/abigail/perl/ch-1.pl48
-rw-r--r--challenge-110/abigail/perl/ch-2.pl34
-rw-r--r--challenge-110/abigail/python/ch-1.py19
-rw-r--r--challenge-110/abigail/python/ch-2.py30
-rw-r--r--challenge-110/abigail/ruby/ch-1.rb18
-rw-r--r--challenge-110/abigail/ruby/ch-2.rb30
-rw-r--r--challenge-110/abigail/t/ctest.ini9
-rw-r--r--challenge-110/abigail/t/input-1-15
-rw-r--r--challenge-110/abigail/t/input-1-25
-rw-r--r--challenge-110/abigail/t/input-2-15
-rw-r--r--challenge-110/abigail/t/output-1-1.exp3
-rw-r--r--challenge-110/abigail/t/output-1-2.exp3
-rw-r--r--challenge-110/abigail/t/output-2-1.exp3
24 files changed, 639 insertions, 71 deletions
diff --git a/challenge-110/abigail/README.md b/challenge-110/abigail/README.md
index efca0f497f..2d2a279ac8 100644
--- a/challenge-110/abigail/README.md
+++ b/challenge-110/abigail/README.md
@@ -1,100 +1,83 @@
# Solutions by Asbigail
-## [Chowla Numbers](https://perlweeklychallenge.org/blog/perl-weekly-challenge-109/#TASK1)
+## [Valid Phone Number Formats](https://perlweeklychallenge.org/blog/perl-weekly-challenge-110/#TASK1)
-Write a script to generate first 20 Chowla Numbers, named after,
-Sarvadaman D. S. Chowla, a London born Indian American mathematician.
-It is defined as:
+> You are given a text file.
+>
+> Write a script to display all valid phone numbers in the given text file.
- C(n) = (sum of divisors of n) - 1 - n
+### 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
+~~~~
+
+### 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.
- 0, 0, 0, 2, 0, 5, 0, 6, 3, 7, 0, 15, 0, 9, 8, 14, 0, 20, 0, 21
+We therefore conclude the examples just contain random spaces, and we
+can completly ignore any white space in the input.
### Solutions
* [AWK](awk/ch-1.awk)
* [Bash](bash/ch-1.sh)
-* [BASIC](basic/ch-1.bas)
-* [bc](bc/ch-1.bc)
-* [Befunge-93][befunge-93/ch-1.bf93]
* [C](c/ch-1.c)
-* [Cobol](cobol/ch-1.cb)
-* [Csh](csh/ch-1.csh)
-* [Erlang](erlang/ch-1.erl)
-* [Forth](forth/ch-1.fs)
-* [Fortran](fortran/ch-1.f90)
-* [Go](go/ch-1.go)
-* [Java](java/ch-1.java)
* [Lua](lua/ch-1.lua)
-* [m4](m4/ch-1.m4)
* [Node.js](node/ch-1.js)
-* [Ocaml](ocaml/ch-1.ml)
-* [Pascal](pascal/ch-1.p)
* [Perl](perl/ch-1.pl)
-* [PHP](php/ch-1.php)
-* [PostScript](postscript/ch-1.ps)
* [Python](python/ch-1.py)
-* [R](r/ch-1.r)
-* [Rexx](rexx/ch-1.rexx)
* [Ruby](ruby/ch-1.rb)
-* [Scheme](scheme/ch-1.scm)
-* [sed](sed/ch-1.sed)
-* [SQL](sql/ch-1.sql)
-* [Tcl](tcl/ch-1.tcl)
### Blog
-[Chowla Numbers](https://abigail.github.io/HTML/Perl-Weekly-Challenge/week-109-1.html)
+## [Transpose File](https://perlweeklychallenge.org/blog/perl-weekly-challenge-110/#TASK2)
+> You are given a text file.
+>
+> Write a script to transpose the contents of the given file.
-## [Four Squares Puzzle](https://perlweeklychallenge.org/blog/perl-weekly-challenge-109/#TASK2)
-
-You are given four squares as below with numbers named `a`, `b`,
-`c`, `d`, `e`, `f`, `g`.
-
- (1) (3)
- ╔══════════════╗ ╔══════════════╗
- ║ ║ ║ ║
- ║ a ║ ║ e ║
- ║ ║ (2) ║ ║ (4)
- ║ ┌───╫──────╫───┐ ┌───╫─────────┐
- ║ │ ║ ║ │ │ ║ │
- ║ │ b ║ ║ d │ │ f ║ │
- ║ │ ║ ║ │ │ ║ │
- ║ │ ║ ║ │ │ ║ │
- ╚══════════╪═══╝ ╚═══╪══════╪═══╝ │
- │ c │ │ g │
- │ │ │ │
- │ │ │ │
- └──────────────┘ └─────────────┘
-
-Write a script to place the given unique numbers in the square box
-so that sum of numbers in each box is the same.
-
-### Example
+### Input File
+~~~~
+name,age,sex
+Mohammad,45,m
+Joe,20,m
+Julie,35,f
+Cristina,10,f
+~~~~
+### Output
~~~~
-Input: 1,2,3,4,5,6,7
-
-Output:
-
- a = 6
- b = 4
- c = 1
- d = 5
- e = 2
- f = 3
- g = 7
-
- Box 1: a + b = 6 + 4 = 10
- Box 2: b + c + d = 4 + 1 + 5 = 10
- Box 3: d + e + f = 5 + 2 + 3 = 10
- Box 4: f + g = 3 + 7 = 10
+name,Mohammad,Joe,Julie,Cristina
+age,45,20,35,10
+sex,m,m,f,f
~~~~
+
### Solutions
* [AWK](awk/ch-2.awk)
-* [Bash](bash/ch-2.sh)
+* [Bash](bash/ch-2.ch)
* [C](c/ch-2.c)
* [Lua](lua/ch-2.lua)
* [Node.js](node/ch-2.js)
@@ -103,5 +86,4 @@ Output:
* [Ruby](ruby/ch-2.rb)
### Blog
-[Four Squares Puzzle](https://abigail.github.io/HTML/Perl-Weekly-Challenge/week-109-2.html)
diff --git a/challenge-110/abigail/awk/ch-1.awk b/challenge-110/abigail/awk/ch-1.awk
new file mode 100644
index 0000000000..f3b7780f04
--- /dev/null
+++ b/challenge-110/abigail/awk/ch-1.awk
@@ -0,0 +1,20 @@
+#!/usr/bin/awk
+
+#
+# See ../README.md
+#
+
+#
+# Run as: awk -f ch-1.awk < input-file
+#
+
+{
+ line = $0;
+ gsub (/ */, "", line) # Remove spaces
+ sub (/^\+/, "00", line) # Replace leading + with 00
+ sub (/^\([0-9]{2}\)/, "0000", line) # Replace leading (NN) with 0000
+}
+
+match (line, /^[0-9]{14}$/) { # Match exactly 14 digits
+ print
+}
diff --git a/challenge-110/abigail/awk/ch-2.awk b/challenge-110/abigail/awk/ch-2.awk
new file mode 100644
index 0000000000..ec9f1acd36
--- /dev/null
+++ b/challenge-110/abigail/awk/ch-2.awk
@@ -0,0 +1,31 @@
+#!/usr/bin/awk
+
+#
+# See ../README.md
+#
+
+#
+# Run as: awk -f ch-2.awk < input-file
+#
+
+BEGIN {
+ FS = "," # This gives us an implicit split
+}
+
+{
+ #
+ # Build output strings in array out
+ #
+ for (i = 1; i <= NF; i ++) {
+ out [i] = out [i] "," $i
+ }
+}
+
+END {
+ #
+ # Print the output strings
+ #
+ for (i = 1; i <= length (out); i ++) {
+ print substr (out [i], 2)
+ }
+}
diff --git a/challenge-110/abigail/bash/ch-1.sh b/challenge-110/abigail/bash/ch-1.sh
new file mode 100644
index 0000000000..8038708208
--- /dev/null
+++ b/challenge-110/abigail/bash/ch-1.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+#
+# See ../README.md
+#
+
+#
+# Run as: bash ch-1.sh < input-file
+#
+
+set -f
+
+IFS="" # This way, we keep the spaces as is.
+
+valid="[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"
+
+while read line
+do raw=${line// } # Remove spaces
+ raw=${raw/#+/00} # Replace leading + with 00
+ raw=${raw/#([0-9][0-9])/0000} # Replace leading (NN) with 0000
+ left=${raw/$valid} # Remove 14 digits
+ if [ "X$left" == "X" ] # If nothing left, the input is valid
+ then echo $line # Print it
+ fi
+done
diff --git a/challenge-110/abigail/bash/ch-2.sh b/challenge-110/abigail/bash/ch-2.sh
new file mode 100644
index 0000000000..38dd956446
--- /dev/null
+++ b/challenge-110/abigail/bash/ch-2.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+#
+# See ../README.md
+#
+
+#
+# Run as: bash ch-2.sh < input-file
+#
+
+
+declare -a out
+
+#
+# Read in the data, add each field to the appropriate output string
+#
+IFS=","
+while read -a chunks
+do for ((i = 0; i < ${#chunks[@]}; i ++))
+ do out[$i]=${out[$i]}${chunks[$i]},
+ done
+done
+
+#
+# Print the output string, dropping the final comma
+#
+IFS=""
+for ((i = 0; i < ${#out[@]}; i ++))
+do echo ${out[$i]:0:-1}
+done
diff --git a/challenge-110/abigail/c/ch-1.c b/challenge-110/abigail/c/ch-1.c
new file mode 100644
index 0000000000..011ef2ee99
--- /dev/null
+++ b/challenge-110/abigail/c/ch-1.c
@@ -0,0 +1,79 @@
+# include <stdlib.h>
+# include <stdio.h>
+# include <string.h>
+# include <ctype.h>
+# include <stdbool.h>
+
+/*
+ * See ../README.md
+ */
+
+/*
+ * Run as: cc -o ch-1.o ch-1.c; ./ch-1.o < input-file
+ */
+
+int main (void) {
+ char * raw = NULL;
+ size_t len = 0;
+ size_t str_len;
+
+ while ((str_len = getline (&raw, &len, stdin)) != -1) {
+ /*
+ * Make a copy of line, but without the spaces
+ */
+ char * line;
+ if ((line = (char *) malloc ((str_len + 2) * sizeof (char))) == NULL) {
+ perror ("Malloc failed");
+ exit (1);
+ }
+ char * raw_ptr = raw;
+ char * line_ptr = line;
+ while (* raw_ptr) {
+ /*
+ * Skip white space
+ */
+ if (isspace (* raw_ptr)) {
+ raw_ptr ++;
+ continue;
+ }
+
+ /*
+ * If the first character is a '+', write two 0s.
+ */
+ if (line_ptr == line && * raw_ptr == '+') {
+ * line_ptr ++ = '0';
+ * line_ptr ++ = '0';
+ raw_ptr ++;
+ continue;
+ }
+ * line_ptr ++ = * raw_ptr ++;
+ }
+ * line_ptr = '\0';
+ /*
+ * If the first character is a '(', and the fourth is a ')',
+ * replace both of them with 0
+ */
+ if (line [0] == '(' && line [3] == ')') {
+ line [0] = '0';
+ line [3] = '0';
+ }
+
+ /*
+ * Check that we have exactly 14 digits
+ */
+ bool valid = true;
+ for (size_t i = 0; i < 14 && valid; i ++) {
+ if (!isdigit (line [i])) {
+ valid = false;
+ }
+ }
+ if (valid && line [14] == '\0') {
+ printf ("%s", raw);
+ }
+
+ free (line);
+ }
+ free (raw);
+
+ return (0);
+}
diff --git a/challenge-110/abigail/c/ch-2.c b/challenge-110/abigail/c/ch-2.c
new file mode 100644
index 0000000000..fe91fbaec8
--- /dev/null
+++ b/challenge-110/abigail/c/ch-2.c
@@ -0,0 +1,83 @@
+# include <stdlib.h>
+# include <stdio.h>
+# include <string.h>
+
+/*
+ * See ../README.md
+ */
+
+/*
+ * Run as: cc -o ch-2.o ch-2.c; ./ch-2.o < input-file
+ */
+
+int main (void) {
+ char * text = NULL;
+ size_t len = 0;
+ size_t str_len;
+
+ if ((str_len = getdelim (&text, &len, '\0', stdin)) == -1) {
+ perror ("Failed to read stdin");
+ exit (1);
+ }
+ /*
+ * Count the number of input lines and columns.
+ */
+ size_t nr_of_lines = 0;
+ size_t nr_of_columns = 0;
+ char * ptr = text;
+ while (* ptr) {
+ if (nr_of_lines == 0) {
+ if (* ptr == ',' || * ptr == '\n') {
+ nr_of_columns ++;
+ }
+ }
+ if (* ptr ++ == '\n') {
+ nr_of_lines ++;
+ }
+ }
+
+ /*
+ * Position pointer at the start of each input line;
+ * turn newlines into commas.
+ */
+ char ** outputs;
+ if ((outputs = (char **) malloc (nr_of_lines * sizeof (char *)))
+ == NULL) {
+ perror ("Malloc failed");
+ exit (1);
+ }
+ ptr = text;
+ size_t c = 0;
+ outputs [0] = ptr;
+ while (* ptr) {
+ if (* ptr == '\n') {
+ * ptr = ',';
+ if (* (ptr + 1) != '\0') {
+ outputs [++ c] = ptr + 1;
+ }
+ }
+ ptr ++;
+ }
+
+ /*
+ * For each line of output, print a column of input.
+ * Field are terminated by commas. For the output, proceed
+ * each field with a comma, except for the first output column.
+ */
+ for (size_t i = 0; i < nr_of_columns; i ++) {
+ for (size_t j = 0; j < nr_of_lines; j ++) {
+ if (j) {
+ printf (",");
+ }
+ while (* outputs [j] != ',') {
+ printf ("%c", * outputs [j] ++);
+ }
+ outputs [j] ++;
+ }
+ printf ("\n");
+ }
+
+
+ free (text);
+ return (0);
+}
diff --git a/challenge-110/abigail/lua/ch-1.lua b/challenge-110/abigail/lua/ch-1.lua
new file mode 100644
index 0000000000..a118074744
--- /dev/null
+++ b/challenge-110/abigail/lua/ch-1.lua
@@ -0,0 +1,24 @@
+#!/opt/local/bin/lua
+
+--
+-- See ../README.md
+--
+
+--
+-- Run as: lua ch-1.lua < input-file
+--
+
+for line in io . lines () do
+ local number = line : gsub (" ", "") -- Remove spaces
+ if -- nnnn nnnnnnnnnn
+ number : find ("^[0-9][0-9][0-9][0-9][0-9][0-9][0-9]" ..
+ "[0-9][0-9][0-9][0-9][0-9][0-9][0-9]$") or
+ -- +nn nnnnnnnnnn
+ number : find ("^%+[0-9][0-9][0-9][0-9][0-9]" ..
+ "[0-9][0-9][0-9][0-9][0-9][0-9][0-9]$") or
+ -- (nn) nnnnnnnnnn
+ number : find ("^%([0-9][0-9]%)[0-9][0-9][0-9]" ..
+ "[0-9][0-9][0-9][0-9][0-9][0-9][0-9]$")
+ then print (line)
+ end
+end
diff --git a/challenge-110/abigail/lua/ch-2.lua b/challenge-110/abigail/lua/ch-2.lua
new file mode 100644
index 0000000000..627fb8176a
--- /dev/null
+++ b/challenge-110/abigail/lua/ch-2.lua
@@ -0,0 +1,32 @@
+#!/opt/local/bin/lua
+
+--
+-- See ../README.md
+--
+
+--
+-- Run as: lua ch-2.lua < input-file
+--
+
+--
+-- Read in the input, split each line on commas, and create
+-- the ouput strings from the split field.
+--
+local output = {}
+for line in io . lines () do
+ local i = 1
+ for field in line : gmatch ("[^,\n]+")
+ do if output [i] == nil
+ then output [i] = ""
+ end
+ output [i] = output [i] .. field .. ","
+ i = i + 1
+ end
+end
+
+--
+-- Print the output
+--
+for _, line in ipairs (output)
+do print (line : sub (1, -2))
+end
diff --git a/challenge-110/abigail/node/ch-1.js b/challenge-110/abigail/node/ch-1.js
new file mode 100644
index 0000000000..783f6ef0be
--- /dev/null
+++ b/challenge-110/abigail/node/ch-1.js
@@ -0,0 +1,21 @@
+#!/usr/local/bin/node
+
+//
+// See ../README.md
+//
+
+//
+// Run as: node ch-1.js < input-file
+//
+
+require ('readline')
+. createInterface ({input: process . stdin})
+. on ('line', _ => {
+ if (_ . replace (/\s+/g, "") // Remove spaces
+ . replace (/^\+/, "00") // Replace leading '+' with 00
+ . replace (/^\([0-9][0-9]\)/, "0000") // Replace leading '(NN)'
+ // with 0000
+ . match (/^[0-9]{14}$/)) { // Match 14 digits
+ console . log (_)
+ }
+})
diff --git a/challenge-110/abigail/node/ch-2.js b/challenge-110/abigail/node/ch-2.js
new file mode 100644
index 0000000000..6f41fcd92f
--- /dev/null
+++ b/challenge-110/abigail/node/ch-2.js
@@ -0,0 +1,29 @@
+#!/usr/local/bin/node
+
+//
+// See ../README.md
+//
+
+//
+// Run as: node ch-2.js < input-file
+//
+
+let out = []
+
+ require ("fs")
+. readFileSync (0) // Read all.
+. toString () // Turn it into a string.
+. split ("\n") // Split on newlines.
+. filter (_ => _ . length) // Filter out empty lines.
+. map (_ => _ . split (',')) // Split each line on commas
+. forEach (_ => _ .
+ forEach ((field, index) => { // Create output strings
+ if (out [index] == null) {
+ out [index] = ""
+ }
+ out [index] += "," + field
+ }))
+
+out . forEach (_ => console . log (_ . substr (1))) // Print the output
+ // strings, skipping the
+ // leading comma.
diff --git a/challenge-110/abigail/perl/ch-1.pl b/challenge-110/abigail/perl/ch-1.pl
new file mode 100644
index 0000000000..c27f7d3ecc
--- /dev/null
+++ b/challenge-110/abigail/perl/ch-1.pl
@@ -0,0 +1,48 @@
+#!/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
+#
+#
+# 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.
+#
+# We therefore conclude the examples just contain random spaces, and we
+# can completly ignore any white space in the input.
+#
+
+#
+# To check for valid phone numbers, we will do the following:
+# - Remove all whitespace
+# - Replace a leading '+' by '00'
+# - Replace a leading '(NN)' by '0000'
+#
+# The number is valid, if and only if we are left with exactly 14 digits.
+#
+
+while (<>) {
+ print if s{\s+} {}gr # Remove white space
+ =~ s{^\+} {00}r # Replace leading + with 00
+ =~ s{^\([0-9]{2}\)} {0000}r # Replace leading (NN) with 0000
+ =~ /^[0-9]{14}$/ # Check if 14 digits are left
+}
+
+
+__END__
diff --git a/challenge-110/abigail/perl/ch-2.pl b/challenge-110/abigail/perl/ch-2.pl
new file mode 100644
index 0000000000..aef60b4713
--- /dev/null
+++ b/challenge-110/abigail/perl/ch-2.pl
@@ -0,0 +1,34 @@
+#!/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 < input-file
+#
+# We make the assumption the input has the same number
+# of fields on each line.
+#
+
+#
+# Read in the data, split into fields, add the fields to a set strings,
+# placed in an array @;. Add commas after each field.
+#
+map {$- = 0; $; [$- ++] .= "$_," for /[^,\n]+/g} <>;
+
+#
+# Remove trailing commas, print lines.
+#
+chop, say for @;
+
+__END__
diff --git a/challenge-110/abigail/python/ch-1.py b/challenge-110/abigail/python/ch-1.py
new file mode 100644
index 0000000000..63e3c8e69e
--- /dev/null
+++ b/challenge-110/abigail/python/ch-1.py
@@ -0,0 +1,19 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-1.py < input-file
+#
+
+import fileinput
+import re
+
+for line in fileinput . input ():
+ plain = re . sub (r'\s+', "", line) # Strip whitespace
+ plain = re . sub (r'^\+', "00", plain) # Replace leading +
+ plain = re . sub (r'^\([0-9][0-9]\)', "0000", plain) # Replace leading (NN)
+ if re . search (r'^[0-9]{14}$', plain): # Chech for 14 digits
+ print (line, end = '')
diff --git a/challenge-110/abigail/python/ch-2.py b/challenge-110/abigail/python/ch-2.py
new file mode 100644
index 0000000000..c5ba11fae6
--- /dev/null
+++ b/challenge-110/abigail/python/ch-2.py
@@ -0,0 +1,30 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-2.py < input-file
+#
+
+import fileinput
+
+outputs = []
+
+#
+# Read input, split on commas, build output strings.
+#
+for line in fileinput . input ():
+ fields = line . rstrip () . split (",")
+ if (len (outputs)):
+ for i in range (len (fields)):
+ outputs [i] = outputs [i] + "," + fields [i]
+ else:
+ outputs . extend (fields)
+
+#
+# Print output lines
+#
+for line in outputs:
+ print (line)
diff --git a/challenge-110/abigail/ruby/ch-1.rb b/challenge-110/abigail/ruby/ch-1.rb
new file mode 100644
index 0000000000..e0ea490dc7
--- /dev/null
+++ b/challenge-110/abigail/ruby/ch-1.rb
@@ -0,0 +1,18 @@
+#!/usr/bin/ruby
+
+#
+# See ../README.md
+#
+
+#
+# Run as: ruby ch-1.rb < input-file
+#
+
+ARGF . each_line do |_|
+ if _ . gsub(/\s+/, "") # Remove white space
+ . sub(/^\+/, "00") # Replace leading + with 00
+ . sub(/^\([0-9]{2}\)/, "0000") # Replace leading (NN) with 0000
+ . match /^[0-9]{14}$/ # Exactly 14 digits should be left
+ then print (_)
+ end
+end
diff --git a/challenge-110/abigail/ruby/ch-2.rb b/challenge-110/abigail/ruby/ch-2.rb
new file mode 100644
index 0000000000..9177342a45
--- /dev/null
+++ b/challenge-110/abigail/ruby/ch-2.rb
@@ -0,0 +1,30 @@
+#!/usr/bin/ruby
+
+#
+# See ../README.md
+#
+
+#
+# Run as: ruby ch-2.rb < input-file
+#
+
+output = []
+
+#
+# Read the input, split on comma, build output strings.
+#
+ARGF . each_line do
+ |_|
+ _ . strip . split(/,/) . each_with_index do
+ |_, i|
+ output [i] = (output [i] || "") + _ + ","
+ end
+end
+
+#
+# Print the output strings, without the trailing commas.
+#
+output . each do
+ |_|
+ puts _ [0 .. -2]
+end
diff --git a/challenge-110/abigail/t/ctest.ini b/challenge-110/abigail/t/ctest.ini
new file mode 100644
index 0000000000..437170d281
--- /dev/null
+++ b/challenge-110/abigail/t/ctest.ini
@@ -0,0 +1,9 @@
+#
+# Configuration file for running tests, using ctest.
+# See https://github.com/Abigail/Misc/blob/master/ctest
+#
+
+[names]
+1-1 = Given Example
+1-2 = More Examples
+2-1 = Given Example
diff --git a/challenge-110/abigail/t/input-1-1 b/challenge-110/abigail/t/input-1-1
new file mode 100644
index 0000000000..48d6254741
--- /dev/null
+++ b/challenge-110/abigail/t/input-1-1
@@ -0,0 +1,5 @@
+0044 1148820341
+ +44 1148820341
+ 44-11-4882-0341
+(44) 1148820341
+ 00 1148820341
diff --git a/challenge-110/abigail/t/input-1-2 b/challenge-110/abigail/t/input-1-2
new file mode 100644
index 0000000000..fa9727d285
--- /dev/null
+++ b/challenge-110/abigail/t/input-1-2
@@ -0,0 +1,5 @@
+12345678901234
+1 2 3 4 5 6 7 8 9 0 1 2 3 4
+123456789012345
+(123)456789012
+(1 2)3456789012
diff --git a/challenge-110/abigail/t/input-2-1 b/challenge-110/abigail/t/input-2-1
new file mode 100644
index 0000000000..716ebdce75
--- /dev/null
+++ b/challenge-110/abigail/t/input-2-1
@@ -0,0 +1,5 @@
+name,age,sex
+Mohammad,45,m
+Joe,20,m
+Julie,35,f
+Cristina,10,f
diff --git a/challenge-110/abigail/t/output-1-1.exp b/challenge-110/abigail/t/output-1-1.exp
new file mode 100644
index 0000000000..c681c2e535
--- /dev/null
+++ b/challenge-110/abigail/t/output-1-1.exp
@@ -0,0 +1,3 @@
+0044 1148820341
+ +44 1148820341
+(44) 1148820341
diff --git a/challenge-110/abigail/t/output-1-2.exp b/challenge-110/abigail/t/output-1-2.exp
new file mode 100644
index 0000000000..1589bf5ea0
--- /dev/null
+++ b/challenge-110/abigail/t/output-1-2.exp
@@ -0,0 +1,3 @@
+12345678901234
+1 2 3 4 5 6 7 8 9 0 1 2 3 4
+(1 2)3456789012
diff --git a/challenge-110/abigail/t/output-2-1.exp b/challenge-110/abigail/t/output-2-1.exp
new file mode 100644
index 0000000000..0cb1eb87a1
--- /dev/null
+++ b/challenge-110/abigail/t/output-2-1.exp
@@ -0,0 +1,3 @@
+name,Mohammad,Joe,Julie,Cristina
+age,45,20,35,10
+sex,m,m,f,f