Create a list of US-state names with one state name per line, so that no two distinct lines on your list contain a common letter. Let $L$ be sum of the lengths of all the state names on your list (blanks/spaces are not counted).
What is the largest possible value for $L$?
Answer
Best I could find was 22.
Mississippi
New York
Utah
If Avarind is correct that the best answer has three states, then we can quickly brute force each 3 state combination to find the result. Sample Python implementation:
import itertools
seq = ["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina","North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"]
def shares_letters(a,b):
return bool(set(a.replace(" ", "").lower()) & set(b.replace(" ", "").lower()))
size = lambda x: len("".join(item.replace(" ", "") for item in x))
print max([candidate for candidate in itertools.permutations(seq, 3) if all(not shares_letters(*pair) for pair in itertools.permutations(candidate,2))], key=size)
Result:
('Mississippi', 'New York', 'Utah')
No comments:
Post a Comment