Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
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.
|
||||
Loading…
Add table
Add a link
Reference in a new issue