English to Braille Translator English to Braille Translator
English RU

Braille is a tactile writing system used by the blind and the visually impaired. It is traditionally written with embossed paper. Braille characters are small rectangular blocks, called cells, which contain tiny palpable bumps called raised dots. The number and arrangement of these dots distinguish one character from another.

We will use a 6-dots Braille alphabet. Each letter can be represented as a 3x2 matrix where 1 is a raised dot and 0 is an empty space.

alphabet alphabet

(Letter W is not original)

Letters should be separated by an empty column. Whitespaces are two empty columns (plus a separator empty column if it is between letters). Various formatting marks indicate the values of the letters that follow them. They have no direct equivalent in print. The most important indicators in English Braille are: "capital" and "number". These marks work as "shift" - only for a follow letter.

formating

We will use several basic punctuation symbols:

punctuation punctuation

You are given a page of text and you should convert it into Braille. The page contains one or several lines represented as a matrix. Each line contains no more than 10 symbols (including non-printed). Lines are separated by one empty row. Symbols are separated by empty columns but there are no separators in beginnings and ends of lines. If text can be placed in one line, then the page width is proportional to the length of the text. If the page has more than one line, then the width is equal to the longer line and the final line is appended by whitespaces.

For example, this is the text "hello 1st World!".

example example

Input: A text as a string.

Output: The page as a list of lists or tuple of tuples with integers (1/0).

Example:

braille_page("hello 1st World!") == (
    (1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1),
    (1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1),
    (0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0),
    (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
    (0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0),
    (0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0),
    (0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0))

How it is used: Braille is an international concept which allow blind people to read written text. The script which you will write for this mission would be useful when parsing braille text and formatting it for printing, or it could be used to translate existing text into braille for others.

Precondition:
0 < len(text)
all(ch in string.ascii_letters + " .,!?-_0123456789" for ch in text)