-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPascal.pas
More file actions
30 lines (26 loc) · 774 Bytes
/
Pascal.pas
File metadata and controls
30 lines (26 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
uses RegExpr;
var
wfile: Text;
_word: String;
wlen: Integer;
maxlen: Integer = 0;
invalid: TRegExpr;
longest: Array of String = NIL;
begin
invalid := TRegExpr.Create('(?i).*[gkmqvwxzio].*');
Assign(wfile, 'words.txt');
Reset(wfile);
while not EOF(wfile) do begin
ReadLn(wfile, _word);
wlen := Length(_word);
if (wlen = maxlen) and not invalid.Exec(_word) then begin
SetLength(longest, Length(longest) + 1);
longest[High(longest)] := _word;
end else if (wlen > maxlen) and not invalid.Exec(_word) then begin
SetLength(longest, 1);
longest[0] := _word;
maxlen := wlen;
end;
end;
for _word in longest do WriteLn(_word);
end.