Skip to content

Instantly share code, notes, and snippets.

@mplanchard
Created April 21, 2016 22:06
Show Gist options
  • Save mplanchard/9ae35b7871447a2f46b97607b204a6a8 to your computer and use it in GitHub Desktop.
Save mplanchard/9ae35b7871447a2f46b97607b204a6a8 to your computer and use it in GitHub Desktop.
Quick and dirty permutations script
from itertools import permutations
def get_combinations(layer):
possibles = (-layer, -layer + 1, 0, layer - 1, layer)
combinations = permutations(possibles, 2)
return_combinations = []
for combination in combinations:
if layer in combination or -layer in combination:
return_combinations.append(combination)
return return_combinations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment