Here's one for all you wordsmiths out there! Write a program or function which takes a list of words and produces a list of all possible concatenative decompositions for each word. For example:
(Note: This is only a small sampling for illustrative purposes. Actual output is far more voluminous.)
afterglow = after + glow afterglow = aft + erg + low alienation = a + lie + nation alienation = a + lien + at + i + on alienation = a + lien + at + ion alienation = alien + at + i + on alienation = alien + at + ion archer = arc + her assassinate = ass + as + sin + ate assassinate = ass + ass + in + ate assassinate = assassin + ate backpedalled = back + pedal + led backpedalled = back + pedalled backpedalled = backpedal + led goatskin = go + at + skin goatskin = goat + skin goatskin = goats + kin hospitable = ho + spit + able temporally = tempo + rally windowed = win + do + wed windowed = wind + owed weatherproof = we + at + her + pro + of yeasty = ye + a + sty
Ok, you get the idea. :-)
- Use any programming language of your choosing. Shortest code by character count for each language wins. This means there is one winner for each language used. The overall winner will be simply the shortest code of all submitted.
- The input list can be a text file, standard input, or any list structure your language provides (list, array, dictionary, set, etc.). The words can be English or any other natural language. (If the list is English words, you'll want to ignore or pre-filter-out single-letter items except for "a" and "i". Similarly, for other languages, you'll want to ignore nonsensical items if they appear in the file.)
- The output list can be a text file, standard output, or any list structure your language uses.
- You can use any input dictionary you like, but you'll probably want to use one that provides sensible words rather than one that provides too many obscure, arcane, or obnubilated words. This the file I used: The Corncob list of more than 58000 English words
This challenge is primarily about writing the code to accomplish the task, but it's also fun to comb through the results...
- What subwords occur most commonly?
- What word can be decomposed into the greatest number of subwords?
- What word can be decomposed the most different ways?
- What words are composed of the largest subwords?
- What decompositions did you find that were the most amusing?