Add-A-Gram


The Problem

As described here.

Add-A-Gram
An "add-a-gram" is a sequence of words formed by starting with a 3-letter word, adding a letter and rearranging to form a 4-letter word, and so on. For example, here are add-a-grams of the words "CREDENTIALS" and "ANACHRONISM":
 
ail + s =
sail + n =
nails + e =
aliens + t =
salient + r =
entrails + c =
clarinets + e =
interlaces + d =
CREDENTIALS (length 11)
mar + c =
cram + h =
march + s =
charms + o =
chromas + n =
monarchs + i =
harmonics + a =
maraschino + n =
ANACHRONISM (length 11)
 
Test your own credentials: given the dictionary found here (1.66MB), what is the longest add-a-gram?

Arthur's Solution

	/ group by count .05 second
	\t w@:(1_'=i,n)-#i:1+!|/n:#:'w
/ reverse w:|2_ w
/ transitions going backwards d:{:[#x;y@&y _lin,/x@\:h _di/:h:!#*x;x]}
/ brute force .17 second \t #(~#d/)(1_)/w
/ add-a-gram s:{x@<x}'w:0:`w.txt
/ count group .05 second \t a:|2_ s(1_'=i,n)-#i:1+!|/n:#:'s
/ backward d:{:[#x;y@&y _lin,/x@\:h _di/:h:!#*x;x]}
/ brute force .14 second (save result) \t #{~#*r::|d\x}(1_)/a
/ forward e:{y@*&y _lin x:{x@<x}'x,/:_ci 97+!26}
/ from first root .00 seconds \t r:(**r)e\1_ r
w s?/:r