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).
(In reply to
mostly computer solution by Charlie)
pierre, south dakota
Open "us states and capitals.csv" For Input As #1
Do
Line Input #1, l$
l = LTrim(RTrim(LCase(l)))
ls$ = l
ix = InStr(l, ",")
If ix Then state$ = Left(l, ix - 1): l = Mid(l, ix + 1)
ix = InStr(l, ",")
If ix Then l = Mid(l, ix + 1)
ix = InStr(l, ",")
If ix Then l = Mid(l, ix + 1)
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 & l & ", " & state & crlf
End If
End If
Loop Until EOF(1)
Close
|
Posted by Charlie
on 2015-09-09 20:01:53 |