Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
so so solution in Clear category for Barcode Reader by kdim
L = (' __ _', ' __ _', ' _ __', ' ____ _', ' _ __', ' __ _', ' _ ____', ' ___ __', ' __ ___', ' _ __')
G = (' _ ___', ' __ __', ' __ __', ' _ _', ' ___ _', ' ___ _', ' _ _', ' _ _', ' _ _', ' _ ___')
R = ('___ _ ', '__ __ ', '__ __ ', '_ _ ', '_ ___ ', '_ ___ ', '_ _ ', '_ _ ', '_ _ ', '___ _ ')
T = ('LLLLLL', 'LLGLGG', 'LLGGLG', 'LLGGGL', 'LGLLGG', 'LGGLLG', 'LGGGLL', 'LGLGLG', 'LGLGGL', 'LGGLGL')
def barcode_reader(barcode):
def getnum(c):
if c in L: return 'L', str(L.index(c))
if c in G: return 'G', str(G.index(c))
if c in R: return 'R', str(R.index(c))
return '', ''
def getcode(c):
x, y = [getnum(c[i:i + 7]) for i in range(3, 45, 7)], [getnum(c[i:i + 7]) for i in range(50, 92, 7)]
lllggg, l, r = ''.join(list(zip(*x))[0]), ''.join(list(zip(*x))[1]), ''.join(list(zip(*y))[1])
f = str(T.index(lllggg)) if lllggg in T else ''
return f + l + r
code = getcode(barcode) if len(getcode(barcode)) == 13 else getcode(barcode[::-1])
check = -sum([int(j) * 3 if i % 2 else int(j) for i, j in enumerate(code[:-1])]) % 10
if barcode[:3] + barcode[45:50] + barcode[-3:] != '_ _ _ _ _ _' or len(code) != 13 or str(check) != code[-1]:
return None
return code
Feb. 13, 2021