Created
May 28, 2018 20:13
-
-
Save michaelteter/a08c553916b424542834f300e14b193e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# There are many ways to do this, but without knowing circumstantial constraints I chose simple/brute-force. | |
def activities_by_location(activities): | |
locations = {} | |
for k,v in activities.items(): | |
for location in v: | |
if location not in locations: | |
locations[location] = [] | |
locations[location].append(k) | |
return locations | |
activities = {"skiing": ["Winter Park", "Park City", "Saalbach"], | |
"surfing": ["Maui", "Arrifana"], | |
"mountain biking": ["Winter Park", "Park City", "Moab", "Maui"]} | |
print(activities_by_location(activities)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment