PERU is NOT the longest name of a country consisting of alternating vowels and consonants.
Neither is CANADA.
What is?
Neither is it the 8-letter Dominica, Kiribati or Suriname, as I had thought after running the first version of the program. Then I got to thinking it's supposed to be one country. Well, maybe we should ignore spaces, so the revised program ignores spaces, and here's the list of countries matching the criterion, with their name lengths:
5 aruba
7 belarus
6 belize
5 benin
6 canada
7 comoros
4 cuba
8 dominica
4 fiji
5 gabon
4 iran
4 iraq
5 italy
5 japan
8 kiribati
6 kosovo
7 lebanon
6 malawi
4 mali
6 mexico
6 monaco
5 nepal
5 niger
4 oman
6 panama
4 peru
5 qatar
7 senegal
5 sudan
8 suriname
4 togo
6 tuvalu
20 united arab emirates
United Arab Emirates is the longest, with, actually, 18 letters and two spaces.
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
Open "country list.txt" For Input As #1
Do
Line Input #1, l$
l = LCase(LTrim(RTrim(l)))
If Len(l) > 1 Then
If Left(l, 1) < "a" Or Left(l, 1) > "z" Then l = Mid(l, 2)
good = 1
For i = 1 To Len(l)
If Mid(l, i, 1) >= "a" And Mid(l, i, 1) <= "z" Then
prevvowel = vowel
If InStr("aeiouy", Mid(l, i, 1)) > 0 Then vowel = 1 Else vowel = 0
If i > 1 And vowel = prevvowel Then good = 0: Exit For
End If
Next
If good Then Text1.Text = Text1.Text & Len(l) & " " & l & crlf
End If
Loop Until EOF(1)
Close 1
Text1.Text = Text1.Text & crlf & " done"
End Sub
|
Posted by Charlie
on 2015-07-22 15:46:50 |