Japt, 85 bytes
97
`...`£`...`hXiU°d}R
where the two pairs of backticks represent strings of seemingly random printable and unprintable characters. Try it online! Output:
achinesses
boninesses
cozinesses
dozinesses
easinesses
fozinesses
gorinesses
hazinesses
ickinesses
jokinesses
keennesses
lazinesses
mazinesses
nosinesses
oozinesses
pipinesses
quadrantes
riminesses
sizinesses
tininesses
uglinesses
vainnesses
warinesses
xylotomies
yeomanries
zaninesses
Explanation
The basic technique is:
97 Set U to 97
`ch
on
...`£ }R Map each line X in this multiline string to:
U°d Take U.toCharCode() and increment U. ["a", "b", "c", ...]
Xi Prepend this to X. ["ach", "bon", "c", ...]
`cozinesses`h Overwrite this onto the beginning of "cozinesses".
["achinesses", "boninesses", "cozinesses", ...]
£ }R Rejoin with newlines and implicitly output.
I found cozinesses
by starting with nesses
as some other answers have used and repeatedly finding the previous letter that appeared the among the most of the 26 letters. Since greedy techniques are not often optimal, I later wrote a script to find the real optimal word:
alphabet="abcdefghijklmnopqrstuvwxyz".split``;
wordlist=alphabet.map(x=>[]);
document.body.innerText.split`\n`.slice(0,-1).map(x=>wordlist[x.charCodeAt()-97].push(x));
f=(q="",n=7,s=0,words=wordlist,z=n&&alphabet.map(x=>[x+q,words.map(y=>[y=y.filter(z=>z[n]==x),t+=0 in y][0],t=0),t]))=>n?z.filter(x=>x[2]>=Math.max(1,...z.map(x=>(x[2]-2)*2/3))).map(x=>f(x[0],n-1,s+26-x[2],x[1])).sort((a,b)=>a[1]-b[1])[0]:[q,s];
console.time("find optimal word");
console.log(f());
console.timeEnd("find optimal word");
(I don't care that it's incredibly ugly. This is how PPCG has taught me to code :P Don't worry, I don't do this in production.)
Anyway, when run in the browser console on the 10-letter word list, this outputs
[ "ozinesses", 57 ]
The 57
being the number of letters that would have to appear in the multiline string. It also took about 17 seconds on my computer, so be patient when you run it.
By replacing the f=
line with
f=(q="",n=9,s=0,words=wordlist,z=n&&alphabet.map(x=>[x+q,words.map(y=>[y=y.filter(z=>z[n]==x),t+=0 in y][0],t=0),t]))=>n?[for(x of z.filter(x=>x[2]>=Math.max(1,...z.map(x=>(x[2]-2)*2/3))))for(y of f(x[0],n-1,s+26-x[2],x[1]))y].sort((a,b)=>a[1]-b[1]).filter((x,i,a)=>x[1]<=a[0][1]+20):[[q,s]];
you can get all suffixes within 20 chars of the optimal one. (Change the 20
at the end to something else to adjust this. Note: this function probably only works in Firefox.) You can find a list of all suffixes under 100 here.
Anyway, from there on it's just a task of finding the word for each letter of the alphabet that has the longest suffix in common with ozinesses
. I wrote a Japt script to do this, as well as compress the necessary prefixes for me and tell me how long the resulting program will be. (You'll have to manually paste the word list between the quotation marks though.)
This explanation was probably somewhat confusing, so please feel free to ask any questions you may have.
1hey, just a small nitpick, the "previous challenge link" links to an answer, not to the challenge itself – Rod – 2017-07-27T16:41:26.970
1Is the output required to be separated with newlines, or can the output be an array/separated with another delimiter? – Herman L – 2017-07-27T17:10:15.293
I'm disappointed that a nudibranch isn't a bank in a nudist colony. – Draco18s no longer trusts SE – 2017-07-27T17:34:17.750
5The rules include 'q' but the example does not. – trichoplax – 2017-07-27T17:53:37.913
Aardwolves are freaking adorable. – MikeTheLiar – 2017-07-27T20:25:36.193