Created
December 11, 2014 05:35
-
-
Save kratsg/d311a9f6b8d6a4af1201 to your computer and use it in GitHub Desktop.
Decode lights over all possible combinations for hex?
This file contains 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
lights = [['g','r'], | |
['y','d'], | |
['r','r'], | |
['b','d'], | |
['g','r'], | |
['b','r'], | |
['y','d'], | |
['p','d'], | |
['b','d'], | |
['r','d'], | |
['b','r']] | |
def encoder(items, key, reverse=False): | |
green, yellow, red, blue, purple, right, down = key | |
translateColors = {'g': green, 'y': yellow, 'r': red, 'b': blue, 'p': purple} | |
translatePositions = {'d': down, 'r': right} | |
color, position = items | |
color = translateColors[color] | |
position = translatePositions[position] | |
if reverse: | |
return ('%s%s' % (position, color)).decode('hex') | |
else: | |
return ('%s%s' % (color, position)).decode('hex') | |
from itertools import combinations | |
hexList = '0123456789abcdef' | |
for colors in combinations(hexList, 5): | |
for directions in combinations(hexList, 2): | |
print colors+directions | |
print "\t", ''.join([encoder(light, colors+directions) for light in lights]) | |
print "\t", '-'*20 | |
print "\t", ''.join([encoder(light, colors+directions, reverse=True) for light in lights]) | |
print '.'*30 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment