Skip to content

Instantly share code, notes, and snippets.

@joshco
Last active July 8, 2023 23:57
Show Gist options
  • Save joshco/54bcd2856b88bce79fc3c57f0b617e96 to your computer and use it in GitHub Desktop.
Save joshco/54bcd2856b88bce79fc3c57f0b617e96 to your computer and use it in GitHub Desktop.
Example
#!/bin/env python
import math
keyvalue=32
colors = [ "RED", "BLUE", "GREEN", "YELLOW", "PURPLE", "PINK", "BROWN", "BLACK" ]
idx =int( math.log(keyvalue,2))
color = colors[idx]
print "Key value " + str(keyvalue) + " idx " + str(idx) + " Color " + color
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment