Forum Discussion
djclements
Aug 12, 2026Silver Contributor
Braille Translator Challenge
Using the Braille Alphabet lookup table provided: Part 1 - convert the given phrase from Braille to words. Part 2 - convert the given phrase from words to Braille. ✅ Solutions should be in the f...
PeterBartholomew1
Sep 06, 2026Silver Contributor
I decided to look at the possibility of extending my conversion to Braille to cover multiline phrases.
The thing I like about using Lambda solutions is that such changes can sometimes be made based upon very localised edits.
WRITEλ = LAMBDA(message,
// This function reads a text message and return the corresponding Braille letters
LET(
chars, MAPλ(message, LAMBDA(line, REGEXEXTRACT(line,".",1))),
charLst, TILECHARλ(BrailleTable, 4, 2),
Braileϑ, TILEλ(BrailleTable, 4, 2),
return, XLOOKUP(chars,charLst,Braileϑ, THUNK("")),
EVALTHUNKARRλ(return)
)
);The changes required were to use MAPλ to allow REGEXEXTRACT to return multiple rows of characters and to allow for a null thunk to be returned for a missing matches.
djclements
Sep 09, 2026Silver Contributor
Very slick! I'm beginning to appreciate the method to your madness. ;)
My Lambda wasn't quite as easy to edit as yours, but it wasn't too bad either. I just had to broaden the Kronecker product explosion when writing, and MAP over 'slices' when reading.
// Part 1:
= BRA2TXT(SLICEROWS(braille,4,3), TOCOL(SLICEROWS(alphabet,4,1),1), BRA2BIN(SLICEROWS(alphabet,4,-3)))
// Part 2:
= BRA2TXT(words, TOCOL(SLICEROWS(alphabet,4,1),1), BRA2BIN(SLICEROWS(alphabet,4,-3)), 1)
// Where:
BRA2BIN = LAMBDA(ref,
BYROW(WRAPROWS(LEN(TOCOL(ref, , 1)), 6), CONCAT)
);
BRA2TXT = LAMBDA(phrase,chr_array,bin_array,[text_to_braille],
IF(
text_to_braille,
LET(
i, SEQUENCE(ROWS(phrase)),
j, SEQUENCE(MAX(LEN(phrase))),
DROP(IF(MID(
INDEX(XLOOKUP(MID(phrase, TOROW(j), 1), chr_array, bin_array, "000000"), TOCOL(i * EXPAND(1, , 4, 1)), TOROW(j * EXPAND(1, , 2, 1))),
TOCOL(i ^ 0 * EXPAND(SEQUENCE(1, 3), , 4, 9)) + TOROW(j ^ 0 * EXPAND(0, , 2, 3)), 1) = "1", "●", ""
), -1)
),
MAP(SEQUENCE(AREAS(phrase)), LAMBDA(area_num, TRIM(CONCAT(XLOOKUP(BRA2BIN(INDEX(phrase, , , area_num)), bin_array, chr_array)))))
)
);
SLICEROWS = LAMBDA(range,size,[keep],
IF(
ROWS(range) > size,
REDUCE(
TAKE(TAKE(range, size), keep),
SEQUENCE(ROUNDUP(ROWS(range) / size, 0) - 1, , size, size),
LAMBDA(ref,num,
(ref, TAKE(TAKE(DROP(range, num), size), keep))
)
),
TAKE(range, keep)
)
);Not a winner in ingenuity by any means, but it was a fun experiment. :)