According to the original Catholic Encyclopedia1 — an English-language encyclopedia published in 1907 that was designed to give its readers full and authoritative information on the entire cycle of Catholic interests, actions and doctrine — the Abecedarians were a 16th-century German sect of Anabaptists2 who affected an absolute disdain for all human knowledge, contending that God would enlighten his elect from within themselves, giving them knowledge of necessary truths by visions and ecstasies, with which human learning would interfere. They rejected every other means of instruction, and claimed that to be saved one must even be ignorant of the first letters of the alphabet. Whence their name: A-B-C-darians.
In the typical one-room schools3 of 19th-century America, abecedarians were the youngest students (then called scholars), so-called because they were just learning their "a-b-cs". By the end of the 19th century, the mere use of the term represented a bygone era of the one-room schoolhouse.
Words that have their letters arranged in alphabetic order are known as abecedarian words (from the Latin word acededarius, meaning "alphabetical"). Although the Oxford English Dictionary defines more than 750,000 English words, only about 860 of them are abecedarian. The longest abecedarian word is Aegilops4 (8 letters). Technically this is a Latin term: Aegilops is a genus of goat grass, the wild ancestor of modern domestic wheat. In medicine, an aegilops is an abscess or ulcer in the outer or inner corner of the eye. However, the longest English words with letters in alphabetical order, containing 7 letters are beefily and billowy. The longest word with letters in reverse alphabetical order is spoon-feed (9 letters).
When Marshall Bean left the Army in 1965 after eight years' service, he inverted his name to avoid his creditors. His new driver's license and social security card read Naeb Llahsram. Unfortunately, this fooled the army too, which drafted him back again in 1966. It took him more than a year to convince them he'd already served. An army spokesman told the Associated Press:
All this is his own fault. It would not have happened in the first place if he hadn't spelled his name backwards.
The above stories are unrelated, except for the fact they inspired us for some word plays that all have something to do with word reversals. Your task:
Write a function abecedarian that takes two strings. The function may assume that the second string contains all letters of the alphabet exactly once, but not necessarily in alphabetic order. The function must return a Boolean value that indicates whether the letters of the first string occur in the same order as the letters in the second string, allowing repetitions of the same letter in succession. The function should not make a distinction between uppercase and lowercase letters, and characters that are no letters should be ignored in determining if the letters of the first string are in the correct order.
Write a function reversal that takes a string containing letters only (both uppercase and lowercase letters are allowed). The function must return the reverse string, with the positions of uppercase and lowercase retained. This means that if the $$i$$-th letter of the given string is uppercase (resp. lowercase), then the $$i$$-th letter of the returned string must be uppercase (resp. lowercase) as well.
Write a function doubleReversal that takes a string containing a sequence of words, separated from each other by a single space. The words may contain letters only (both uppercase and lowercase letters are allowed). The function must return a string that contains the given sequence of words in reverse order, separated from each other by a single space. In addition, the order of the letters in each word must be reversed as well, retaining the positions of uppercase and lowercase in each word.
>>> abecedarian('Aegilops', 'abcdefghijklmnopqrstuvwxyz')
True
>>> abecedarian('billowy', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
True
>>> abecedarian('spoon-feed', 'abcdefghijklmnopqrstuvwxyz')
False
>>> abecedarian('spoon-feed', 'zyxwvutsrqponmlkjihgfedcba')
True
>>> reversal('Marshall')
'Llahsram'
>>> reversal('BeAn')
'NaEb'
>>> reversal('Aegilops')
'Spoligea'
>>> doubleReversal('Marshall Bean')
'Naeb Llahsram'
>>> doubleReversal('Barak Obama')
'Amabo Karab'
>>> doubleReversal('Yitzhak Rabin')
'Nibar Kahztiy'
>>> doubleReversal('Jar Jar Binks')
'Sknib Raj Raj'
>>> doubleReversal('Klat Rehctub')
'Butcher Talk'
On page 22 in The Calculus Affair5 — the eighteenth volume of The Adventures of Tintin6, the comics series by Belgian cartoonist Hergé — Captain Haddock uses the word "Abecedarians" as an epithet.
It's not only 007 who communicates in code. Butchers in Australia speak a secret language called Rechtub Klat (butcher talk), in which words are pronounced backward. Why should butchers need a secret language? So they can talk about the customers:
Kool, toh lirg = Look, hot girl
Doog tsub = Good bust
Doog esra = Good arse
On doog cuf ecaf = No-good fuckface
Keep your ears open.