Find words whose first and last three letters are equal: Difference between revisions
Content added Content deleted
(add lambdatalk code) |
No edit summary |
||
Line 262: | Line 262: | ||
8. testes |
8. testes |
||
</pre> |
</pre> |
||
=={{header|Delphi}}== |
|||
{{works with|Delphi|6.0}} |
|||
{{libheader|SysUtils,StdCtrls}} |
|||
Runs in 13 ms. |
|||
<syntaxhighlight lang="Delphi"> |
|||
var Dict: TStringList; {List holds dictionary} |
|||
procedure FindFirst3Last3Match(Memo: TMemo); |
|||
{Find words where the first and last 3 characters are identical} |
|||
var I,Cnt: integer; |
|||
var First3,Last3: string; |
|||
begin |
|||
Cnt:=0; |
|||
for I:=0 to Dict.Count-1 do |
|||
if Length(Dict[I])>5 then |
|||
begin |
|||
First3:=Copy(Dict[I],1,3); |
|||
Last3:=Copy(Dict[I],Length(Dict[I])-2,3); |
|||
if First3=Last3 then |
|||
begin |
|||
Inc(Cnt); |
|||
Memo.Lines.Add(Dict[I]); |
|||
end |
|||
end; |
|||
end; |
|||
initialization |
|||
{Create/load dictionary} |
|||
Dict:=TStringList.Create; |
|||
Dict.LoadFromFile('unixdict.txt'); |
|||
Dict.Sorted:=True; |
|||
finalization |
|||
Dict.Free; |
|||
end. |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
antiperspirant |
|||
calendrical |
|||
einstein |
|||
hotshot |
|||
murmur |
|||
oshkosh |
|||
tartar |
|||
testes |
|||
</pre> |
|||
=={{header|F_Sharp|F#}}== |
=={{header|F_Sharp|F#}}== |