Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Visual solution in Clear category for English to Braille Translator by veky
def braille_page(text: str):
def rows(code):
f, e, d, c, b, a = format(code, "06b")
yield [a, d]
yield [b, e]
yield [c, f]
R = " a,b*k*l*cif*msp*e-h*o!r*djg*ntq$***_u?v*****x****.**z******#yw*"
coded = []
for c in text:
if c.isupper(): coded += ["$", c.lower()]
elif c.isdigit(): coded += ["#", "jabcdefghi"[int(c)]]
else: coded.append(c)
grid = [[0] * (min(len(coded), 10) * 3 - 1) for line in range(3)]
for index, point in enumerate(coded):
offset = index % 10 * 3
if offset == 0 < index: grid.extend([0] * 29 for line in range(4))
for row, etch in zip(grid[index // 10 * 4 :], rows(R.index(point))):
row[offset : offset + 2] = map(int, etch)
return grid
Oct. 16, 2014
Comments: