Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generates valid click codes for Google I/O 2013
forbidden_starts = filter(bool,
'''
000
00100
0010100
00101011
001011
00110
00111000
0011101
001111
010000
01000100
0100011
01001
0101000
01010010
010101
01011
0110
011100
01110100
0111011
011110
0111110
01111110
10000000
1000001
100001
10001001
1000101
100011
10010001
1001001
100101
10011
101
1100
1101000
11010010
110101
1101100
11011010
110111
111000
1110010
11100110
11101
1111
'''.split()
)
def is_allowed(num):
bitstring = '{0:08b}'.format(num)
if any(map(lambda p: bitstring.startswith(p), forbidden_starts)):
return False
return True
for num in filter(is_allowed, range(256)):
print '{0:08b}'.format(num)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment