Find words which contains more than 3 e vowels: Difference between revisions
Content added Content deleted
(add sed) |
No edit summary |
||
Line 700: | Line 700: | ||
tennessee |
tennessee |
||
</pre> |
</pre> |
||
=={{header|Delphi}}== |
|||
{{works with|Delphi|6.0}} |
|||
{{libheader|Classes,StdCtrls,SysUtils}} |
|||
This program makes extensive use of the standard Delphi TStringList component. It holds the dictionary, which is preloaded. It capture the E-Vowel-only information in a TStringList and uses it to display the words. |
|||
<syntaxhighlight lang="Delphi"> |
|||
var Dict: TStringList; {List holds dictionary} |
|||
function HasEVowels(S: string): boolean; |
|||
{Test if string has exclusively E-Vowels and no "a,i,o,u"} |
|||
var I,ECount: integer; |
|||
begin |
|||
Result:=False; |
|||
ECount:=0; |
|||
for I:=1 to Length(S) do |
|||
begin |
|||
if S[I] in ['a','i','o','u'] then exit; |
|||
if S[I]='e' then Inc(ECount); |
|||
end; |
|||
Result:=ECount>3; |
|||
end; |
|||
procedure ShowEVowels(Memo: TMemo); |
|||
{Show words in dictionary that only} |
|||
{have e-vowels and have at least three} |
|||
var I: integer; |
|||
var SL: TStringList; |
|||
var S: string; |
|||
begin |
|||
SL:=TStringList.Create; |
|||
try |
|||
{Make list of words with least three E-vowels} |
|||
for I:=0 to Dict.Count-1 do |
|||
if HasEVowels(Dict[I]) then SL.Add(Dict[I]); |
|||
{Display all the words found} |
|||
S:='Found: '+IntToStr(SL.Count)+#$0D#$0A; |
|||
for I:=0 to SL.Count-1 do |
|||
begin |
|||
S:=S+Format('%-23s',[SL[I]]); |
|||
if (I mod 4)=3 then S:=S+#$0D#$0A; |
|||
end; |
|||
Memo.Text:=S; |
|||
finally SL.Free; end; |
|||
end; |
|||
initialization |
|||
{Create/load dictionary} |
|||
Dict:=TStringList.Create; |
|||
Dict.LoadFromFile('unixdict.txt'); |
|||
Dict.Sorted:=True; |
|||
finalization |
|||
Dict.Free; |
|||
end. |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
Found: 16 |
|||
belvedere dereference elsewhere erlenmeyer |
|||
evergreen everywhere exegete freewheel |
|||
nevertheless persevere preference referee |
|||
seventeen seventeenth telemeter tennessee |
|||
</pre> |
|||
=={{header|Draco}}== |
=={{header|Draco}}== |