Last active
August 9, 2017 08:29
-
-
Save yammesicka/624959a3a9ccbbe4dfaec5735045e55b to your computer and use it in GitHub Desktop.
Which states can be spelled out using a single keyboard row
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
import string | |
import requests | |
STATES_URL = 'http://www.wefeelfine.org/data/files/states.txt' | |
KEYBOARD_ROWS = ('qwertyuiop', 'asdfghjkl', 'zxcvbnm') | |
KEYBOARD = tuple(map(set, KEYBOARD_ROWS)) | |
STATES = tuple(map(set, requests.get(STATES_URL).text.splitlines())) | |
assert set(string.ascii_lowercase) == set(''.join(KEYBOARD_ROWS)) | |
assert len(STATES) == 50 | |
for state, row_letters in itertools.product(STATES, KEYBOARD): | |
if state <= row_letters: | |
print(state) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment