This file contains hidden or 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
def encode(n): | |
if (n > 63) | (n < 0): | |
raise Exception('Out of range {0}'.format(n)) | |
ret = bin(n)[2:] # [2:] to chop off the "0b" part # creating initial bit encoding (for bits 3-8) | |
ret += reduce(lambda a,b: '1' if (a != b) else '0', ret) # adding checksum as bit 9 | |
pad = ''.join(['0'] * (9 - len(ret))) | |
return pad + ret # padding with leading zeros by spec (for bits 1-2 and maybe more for lower ids) | |
def decode(arr): | |
if (len(arr) != 9): |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
// Autoload the 'corechart' visualization library, as described in: | |
// http://code.google.com/apis/chart/interactive/docs/library_loading_enhancements.html#enhancedloading | |
// | |
// the 'autoload' parameter is URI encoded. | |
<script type="text/javascript" src="https://www.google.com/jsapi?autoload=%7B%22modules%22%3A%5B%7B%22name%22%3A%22visualization%22%2C%22version%22%3A%221%22%2C%22packages%22%3A%5B%22corechart%22%5D%7D%5D%7D"></script> | |
</head> | |
<body> |