Skip to content

Instantly share code, notes, and snippets.

@osoleve
Last active December 6, 2019 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save osoleve/2b2e6c66b26ec20930902d205af1fbd4 to your computer and use it in GitHub Desktop.
Save osoleve/2b2e6c66b26ec20930902d205af1fbd4 to your computer and use it in GitHub Desktop.
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