Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. def part_two_fancy(ids):
  2. seen = set()
  3. for id in ids:
  4. #iteratively blank out each character in the id. Ex. "123" becomes "_23" and "1_3" and "12_"
  5. for i in range(len(id)):
  6. blanked_id = "".join("_" if idx==i else c for idx,c in enumerate(id))
  7. if blanked_id in seen:
  8. return blanked_id.replace("_", "")
  9. seen.add(blanked_id)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement