Skip to content

Instantly share code, notes, and snippets.

View nilp0inter's full-sized avatar

Roberto Abdelkader Martínez Pérez nilp0inter

View GitHub Profile
class Gray:
def __init__(self, length):
self.length = length
def _gen(self, start, end, n):
if n == 1:
yield (start, )
yield (end, )
else:
for s in Gray(n-1):
@nilp0inter
nilp0inter / gray2.py
Created August 28, 2014 21:21
Gray codes generator
class Gray:
def __init__(self, length):
self.length = length
def _right(self, n):
if n == 1:
yield (0,)
yield (1,)
else:
for s in Gray(n-1):
import sys
BAD_VERSIONS = [
(2, 4),
(2, 5),
(2, 6) ]
TRANSLATE_TEXT = sys.version_info[:2] in BAD_VERSIONS