a. (easy) What is the only U.S. state name that can be typed on a single row of keys on a standard QWERTY typewriter?
b. (harder) What are the countries,which names can be typed like in a.
c. (difficult) Same for capitals (of countries and US states).
a. non-computer: Alaska
b. computer: Peru
c. computer: Dhaka, Bangladesh,
Quito, Ecuador
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 = LTrim(RTrim(LCase(l)))
If Len(l) > 1 Then
good1 = 1
For i = 1 To Len(l)
If InStr("qwertyuiop", Mid(l, i, 1)) = 0 Then good1 = 0: Exit For
Next
good2 = 1
For i = 1 To Len(l)
If InStr("asdfghjkl", Mid(l, i, 1)) = 0 Then good2 = 0: Exit For
Next
good3 = 1
For i = 1 To Len(l)
If InStr("zxcvbnm", Mid(l, i, 1)) = 0 Then good3 = 0: Exit For
Next
If good1 Or good2 Or good3 Then
Text1.Text = Text1.Text & l & crlf
End If
End If
Loop Until EOF(1)
Close
Text1.Text = Text1.Text & crlf
Open "capital of country.txt" For Input As #1
Do
Line Input #1, l$
l = LTrim(RTrim(LCase(l)))
ls$ = l
ix = InStr(l, ",")
If ix Then l = Left(l, ix - 1)
If Len(l) > 1 Then
good1 = 1
For i = 1 To Len(l)
If InStr("qwertyuiop", Mid(l, i, 1)) = 0 Then good1 = 0: Exit For
Next
good2 = 1
For i = 1 To Len(l)
If InStr("asdfghjkl", Mid(l, i, 1)) = 0 Then good2 = 0: Exit For
Next
good3 = 1
For i = 1 To Len(l)
If InStr("zxcvbnm", Mid(l, i, 1)) = 0 Then good3 = 0: Exit For
Next
If good1 Or good2 Or good3 Then
Text1.Text = Text1.Text & ls & crlf
End If
End If
Loop Until EOF(1)
Close
Text1.Text = Text1.Text & crlf & " done"
End Sub
Files adapted from Wikipedia lists. Additional tidbit of information about Quito, Equador: "highest official capital (2,850 m).[8]"
|
Posted by Charlie
on 2015-09-09 15:49:58 |