Skip to content

Instantly share code, notes, and snippets.

@zahash
Created January 5, 2019 06:59
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 zahash/a3e87dfd8d408ca4832d7dac52135e63 to your computer and use it in GitHub Desktop.
Save zahash/a3e87dfd8d408ca4832d7dac52135e63 to your computer and use it in GitHub Desktop.
def eliminate(grid_dict):
for k,v in grid_dict.items():
if len(v) != 1: # if the box needs elimination
peers = peer_dict[k] # get all the peers
peer_values = set([grid_dict[p] for p in peers if len(grid_dict[p]) == 1])
grid_dict[k] = ''.join(set(grid_dict[k]) - peer_values)
return grid_dict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment