Last active
December 6, 2019 23:44
-
-
Save osoleve/2b2e6c66b26ec20930902d205af1fbd4 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
orbits = {y:x for x,y in [x.split(')') for x in ip.split("\n")]} | |
def indirect_orbits(obj, orbits): | |
if obj not in orbits: | |
return [] | |
return [orbits[obj]] + indirect_orbits(orbits[obj], orbits) | |
def orbital_swaps_setbased(start, end, orbits): | |
steps = 0 | |
left = set(indirect_orbits(start, orbits)) | |
right = set(indirect_orbits(end, orbits)) | |
return len(left ^ right) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment