import util. max_length(Words) = Max => Lengths = [len(W): W in Words], Max = max(Lengths). min_abbr([]) = 0. min_abbr(Line) = Min => Words = split(Line), Max = max_length(Words), I = 0, Abbrevs = [], Uniqs = [], do I := I + 1, Abbrevs := [slice(W, 1, I): W in Words], Uniqs := sort_remove_dups(Abbrevs) while (I < Max, len(Abbrevs) > len(Uniqs)), Min = I. main(Args) => File = Args[1], Reader = open(File), while (not at_end_of_stream(Reader)) Line := read_line(Reader), Min := min_abbr(Line), if (Min > 0) then printf("%d %s\n", Min, Line) else nl end end.