program GetPatternWord; var str, str1, pat, patword: string[255]; n: integer; Infile: text; function patstr (cstr: string): string; var i, j, ls: integer; dstr: string[255]; tpat: array[1..50]of integer; begin dstr := ''; { start with blank string } ls := length(cstr); { get length of string } for i := 1 to ls - 1 do for j := i + 1 to ls do if cstr[i] = cstr[j] then { found a duplicate } begin tpat[i] := j - i; { gives integer distance } break; { found one for this i, don't look further } end else tpat[i] := 0; { no duplicate found for this i } for i := 1 to ls - 1 do { ignore last position: it is 0 } if tpat[i] > 9 then dstr := concat(dstr, chr(tpat[i] + 55)) { letter } else dstr := concat(dstr, chr(tpat[i] + 48)); { number } patstr := dstr; { result returned by function } end; { of function patstr } begin { main program } write('ENTER THE WORD WHOSE PATTERN YOU ARE SEARCHING FOR: '); readln(pat); { read into string pat } n := length(pat); patword := patstr(pat); { pattern string to be matched } write('ENTER THE NAME OF OF THE WORD LIST TO BE SEARCHED: '); readln(str1); reset(Infile, str1); { open word list } while not eof(Infile) do { go through entire word list } begin readln(Infile, str); { read a word into str } if length(str) = n then if patstr(str) = patword then writeln(str); end; { of while } end.