# Shift Braille down

Braille Patterns in Unicode contains 8 dots(⣿) and occupy area U+2800-U+28FF. Given a Braille Pattern character, where the bottom two dots are not used(aka. U+2800-U+283F), shift it down by one dot.

Test cases:

⠀ => ⠀ (U+2800 -> U+2800)
⠅ => ⡂
⠕ => ⡢
⠿ => ⣶


Shortest code wins.

• Are input/output allowed to be in unicode codepoints? Commented Aug 12, 2023 at 8:04
• TIL: Braille is an SBCS. Commented Aug 12, 2023 at 12:11
• This is useful converting Japanese Braille, it extends two dots above
– l4m2
Commented Aug 12, 2023 at 12:39

# Python, 44 bytes

lambda c:chr((d:=ord(c))+d%64+14*(d&36)%192)


Attempt This Online!

Takes and returns a Unicode character.

# Python, 29 bytes

lambda c:c+c%64+14*(c&36)%192


Attempt This Online!

Takes and returns a code point.

### Python, 33 bytes

lambda c:c+c%64+2*(c&32)+14*(c&4)


Attempt This Online!

Takes and returns a code point.

• c+c%64+14*(c&36)%192 is near-polyglot in many languages. Commented Aug 12, 2023 at 9:16
• Accepted only as 1.5 upvote, not much meaning
– l4m2
Commented Aug 12, 2023 at 11:49

# Jelly, 7 bytes

B⁽1¢œ?Ḅ


Try It Online!

I/O via unicode codepoints.

## Explanation

B⁽1¢œ?Ḅ    Main Link
B          Convert to binary
⁽1¢œ?     Take the 13252nd permutation, which shuffles the last 8 bits into place
Ḅ    Convert from binary


My original idea was to chop off the first 7 bits to apply permutation and then add 10240, but Lynn made the clever observation that permutation number 13252 only modifies the last 8 bits so it's not needed to do those precomputation and postcomputation steps.

-5 bytes thanks to emanresu A and Jonathan Allan by using a more convenient input format.
-6 bytes thanks to Lynn by noticing that removing and re-adding the first 7 bits is not needed

• It looks like this only needs to work for single characters? So you can probably save at least the €s Commented Aug 12, 2023 at 7:45
• You could even define it as a link which takes a single character, which you can't pass as an input but can pass as a link argument. Commented Aug 12, 2023 at 20:47
• Don't you mean ḢOBṫ7⁽1¢œ?Ḅ+⁽$ṁỌ? (Œ? is meant to be a monad.) Also yeah, have a link that accepts a character, so OBṫ7⁽1¢œ?Ḅ+⁽$ṁỌ ...perhaps accepting and yielding codepoints is fine too so Bṫ7⁽1¢œ?Ḅ+⁽$ṁ? Commented Aug 13, 2023 at 1:39 • 7 bytes: B⁽1¢œ?Ḅ – lynn Commented Aug 13, 2023 at 16:46 • The reason @ made Œ? work is because (a) its callable function (permutation_index) accepts two arguments and (b) @ has a callable that consumes both arguments and creates a dyadic link (call = lambda x, y: dyadic_link(link, (y, x))). Furthermore, the permutation_index function is the same callable that œ? uses. Commented Aug 13, 2023 at 19:24 # JavaScript (ES6), 25 bytes Expects and returns a code point. n=>n+n%64+((n/4&9)+3^3)*8  Try it online! ### 23 bytes A port of loopy walt's solution is shorter. n=>n+n%64+14*(n&36)%192  Try it online! # Retina, 178163 150 bytes . 255*x Yx⠁-⣿ ~).+ Y$0$-1 ~(KT⠂⣿⠂⠆⡀⡆⠐⠖⡐⡖⠠⠦⡠⡦⠰⠶⡰⡶⢀⢆⣀⣆⢐⢖⣐⣖⢠⢦⣠⣦⢰⢶⣰⣶ -  Try it online! -15 with another eval stage -6 directly thanks to Neil and -7 extrapolating from his suggestions Shaves a few bytes off direct transliteration by spending 40 on an incredibly convoluted way of "doubling" the input so the final transliteration stage can use more ranges. The doubling is necessary because every possible output is even; if the bits in a byte are 76543210 then the dots in the corresponding Braille character are 0 3 1 4 2 5 6 7  (Although this handles longer inputs fine, in the explanation I'll assume only the single character input required by the challenge for the sake of simplicity.) # Explanation: The entire program consists of two eval stages, which construct then run Retina programs: ## Eval stage 1 . 255*x  Replace any and all characters in the input with 255 copies of the letter x. Yx⠁-⣿  Cycling transliterate those into the range of all 255 nonzero Braille characters. This creates that range as a string.   Replace the empty string with a space, prepending a space to every character in the range and appending another to the end. .+ Y$0\$-1


Interpolate the spaced range and the unspaced range into the string representation of a cyclic transliterate.

## Eval stage 2

KT⠂⣿⠂⠆⡀⡆⠐⠖⡐⡖⠠⠦⡠⡦⠰⠶⡰⡶⢀⢆⣀⣆⢐⢖⣐⣖⢠⢦⣠⣦⢰⢶⣰⣶


The literal string T⠂⣿⠂⠆⡀⡆⠐⠖⡐⡖⠠⠦⡠⡦⠰⠶⡰⡶⢀⢆⣀⣆⢐⢖⣐⣖⢠⢦⣠⣦⢰⢶⣰⣶.


-


Replace the empty string with a hyphen, prepending a hyphen to every character in the string and appending another to the end.

## What actually gets run on the input

Y ⠁ ⠂ ⠃ ⠄ ⠅ ⠆ ⠇ ⠈ ⠉ ⠊ ⠋ ⠌ ⠍ ⠎ ⠏ ⠐ ⠑ ⠒ ⠓ ⠔ ⠕ ⠖ ⠗ ⠘ ⠙ ⠚ ⠛ ⠜ ⠝ ⠞ ⠟ ⠠ ⠡ ⠢ ⠣ ⠤ ⠥ ⠦ ⠧ ⠨ ⠩ ⠪ ⠫ ⠬ ⠭ ⠮ ⠯ ⠰ ⠱ ⠲ ⠳ ⠴ ⠵ ⠶ ⠷ ⠸ ⠹ ⠺ ⠻ ⠼ ⠽ ⠾ ⠿ ⡀ ⡁ ⡂ ⡃ ⡄ ⡅ ⡆ ⡇ ⡈ ⡉ ⡊ ⡋ ⡌ ⡍ ⡎ ⡏ ⡐ ⡑ ⡒ ⡓ ⡔ ⡕ ⡖ ⡗ ⡘ ⡙ ⡚ ⡛ ⡜ ⡝ ⡞ ⡟ ⡠ ⡡ ⡢ ⡣ ⡤ ⡥ ⡦ ⡧ ⡨ ⡩ ⡪ ⡫ ⡬ ⡭ ⡮ ⡯ ⡰ ⡱ ⡲ ⡳ ⡴ ⡵ ⡶ ⡷ ⡸ ⡹ ⡺ ⡻ ⡼ ⡽ ⡾ ⡿ ⢀ ⢁ ⢂ ⢃ ⢄ ⢅ ⢆ ⢇ ⢈ ⢉ ⢊ ⢋ ⢌ ⢍ ⢎ ⢏ ⢐ ⢑ ⢒ ⢓ ⢔ ⢕ ⢖ ⢗ ⢘ ⢙ ⢚ ⢛ ⢜ ⢝ ⢞ ⢟ ⢠ ⢡ ⢢ ⢣ ⢤ ⢥ ⢦ ⢧ ⢨ ⢩ ⢪ ⢫ ⢬ ⢭ ⢮ ⢯ ⢰ ⢱ ⢲ ⢳ ⢴ ⢵ ⢶ ⢷ ⢸ ⢹ ⢺ ⢻ ⢼ ⢽ ⢾ ⢿ ⣀ ⣁ ⣂ ⣃ ⣄ ⣅ ⣆ ⣇ ⣈ ⣉ ⣊ ⣋ ⣌ ⣍ ⣎ ⣏ ⣐ ⣑ ⣒ ⣓ ⣔ ⣕ ⣖ ⣗ ⣘ ⣙ ⣚ ⣛ ⣜ ⣝ ⣞ ⣟ ⣠ ⣡ ⣢ ⣣ ⣤ ⣥ ⣦ ⣧ ⣨ ⣩ ⣪ ⣫ ⣬ ⣭ ⣮ ⣯ ⣰ ⣱ ⣲ ⣳ ⣴ ⣵ ⣶ ⣷ ⣸ ⣹ ⣺ ⣻ ⣼ ⣽ ⣾ ⣿⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿⡀⡁⡂⡃⡄⡅⡆⡇⡈⡉⡊⡋⡌⡍⡎⡏⡐⡑⡒⡓⡔⡕⡖⡗⡘⡙⡚⡛⡜⡝⡞⡟⡠⡡⡢⡣⡤⡥⡦⡧⡨⡩⡪⡫⡬⡭⡮⡯⡰⡱⡲⡳⡴⡵⡶⡷⡸⡹⡺⡻⡼⡽⡾⡿⢀⢁⢂⢃⢄⢅⢆⢇⢈⢉⢊⢋⢌⢍⢎⢏⢐⢑⢒⢓⢔⢕⢖⢗⢘⢙⢚⢛⢜⢝⢞⢟⢠⢡⢢⢣⢤⢥⢦⢧⢨⢩⢪⢫⢬⢭⢮⢯⢰⢱⢲⢳⢴⢵⢶⢷⢸⢹⢺⢻⢼⢽⢾⢿⣀⣁⣂⣃⣄⣅⣆⣇⣈⣉⣊⣋⣌⣍⣎⣏⣐⣑⣒⣓⣔⣕⣖⣗⣘⣙⣚⣛⣜⣝⣞⣟⣠⣡⣢⣣⣤⣥⣦⣧⣨⣩⣪⣫⣬⣭⣮⣯⣰⣱⣲⣳⣴⣵⣶⣷⣸⣹⣺⣻⣼⣽⣾⣿


The program generated and run in eval stage 1. Transliterates the input to the character at twice its index in the Braille range, "doubling" it.

-T--⠂-⣿--⠂-⠆-⡀-⡆-⠐-⠖-⡐-⡖-⠠-⠦-⡠-⡦-⠰-⠶-⡰-⡶-⢀-⢆-⣀-⣆-⢐-⢖-⣐-⣖-⢠-⢦-⣠-⣦-⢰-⢶-⣰-⣶-


The program generated and run in eval stage 2. Transliterates the doubled input into a bunch of smaller ranges.

The ranges are non-overlapping pairs of non-hyphens in the to section after the rightmost backtick; the hyphens not inside those pairs parse as literal hyphens which are used for alignment (as the whole point of this is that the from range, between the backticks, is not doubled.) The final hyphen in both the from and to sections is completely irrelevant and the leading hyphens cancel each other out; the extra hyphens before the first backtick are just ignored.

• If you make the second transliterate non-cyclic then you can just replace the empty string with a space to space out all of the Braille characters saving three bytes. You can save another three bytes by prepending the final transliterate command to the beginning of the --separated string.
– Neil
Commented Aug 13, 2023 at 8:47
• Well, that's even better than my second suggestion, but my first suggestion still stands.
– Neil
Commented Aug 13, 2023 at 9:26
• Oh, huh, I managed to test the first suggestion and write it into the explanation but not actually leave it in the program somehow. Commented Aug 13, 2023 at 9:32

# Go, 45 bytes

func(c rune)rune{return c+c%64+14*(c&36)%192}


Try it online!

Port of loopy walt's Python answer.

# Python, 77 64 bytes

-2 bytes thanks to l4m2

lambda c:[c&32and(c:=c&~32|64),c&4and(c:=c&~4|32),c*2-0x2800][2]


Attempt This Online!

Input/output in Unicode codepoints.

## Ungolfed

def f(c):
# fix exceptions (Historical Reasons™)
if c & 32: # change bit 7 set to bit 8 set
c &= ~32
c |= 64
if c & 4: # change bit 4 set to bit 7 set
c &= ~4
c |= 32
return (c << 1) - 0x2800

• Why not do the 0x2800 only once?
– l4m2
Commented Aug 12, 2023 at 8:12
• @l4m2 What do you mean by that? Commented Aug 12, 2023 at 8:13
• sth like this
– l4m2
Commented Aug 12, 2023 at 8:15
• Ah, you're right Commented Aug 12, 2023 at 8:17

# J, 12 bytes

13251#.@A.#:


Attempt This Online!

Apparently converged at the same algorithm as Jelly, because both have the "nth permutation" built-in. (This is not magically winning against Jelly; the direct translation is Lynn's 7-byter in the comments.)

Looking at the lower 8 bits of a Braille's codepoint (highest bit first), the main task is to permute the first into the second:

 0  0 b2 b3 b4 b5 b6 b7
b2 b5 b3 b4  0 b6 b7  0


It doesn't matter which of the two guaranteed zeros go first, so 13257 also works in place of 13251. Jelly uses 13252 instead because its built-in is 1-indexed instead of 0-indexed.

# Charcoal, 23 bytes

℅Σ⟦℅θ＆℅θ⁶³×¹⁴＆℅θ⁴⊗＆℅θ³²


Try it online! Link is to verbose version of code. Explanation: Port of @loopywalt's original Python answer.

    θ                   Input character
℅                    Code of character
θ                Input character
℅                 Code of character
＆                  Bitwise And
⁶³              Literal integer 63
θ        Input character
℅         Code of character
＆          Bitwise And
⁴       Literal integer 4
×             Multiplied by
¹⁴           Literal integer 14
θ   Input character
℅    Code of character
＆     Bitwise And
³² Literal integer 32
⊗     Doubled
⟦                     Make into list
Σ                      Take the sum
℅                       Character with code
Implicitly print


Alternative version, also 23 bytes:

≔℅Ｓθ℅Σ⟦θ＆θ⁶³×¹⁴＆θ⁴⊗＆θ³²


Try it online! Link is to verbose version of code.

24 bytes for a whole string at once:

⭆ＥＳ℅ι℅Σ⟦ι＆ι⁶³×¹⁴＆ι⁴⊗＆ι³²


Try it online! Link is to verbose version of code.

# Retina 0.8.2, 199 bytes

T⠁-⠿⠂⠄⠆⡀⡂⡄⡆⠐⠒⠔⠖⡐⡒⡔⡖⠠⠢⠤⠦⡠⡢⡤⡦⠰⠲⠴⠶⡰⡲⡴⡶⢀⢂⢄⢆⣀⣂⣄⣆⢐⢒⢔⢖⣐⣒⣔⣖⢠⢢⢤⢦⣠⣢⣤⣦⢰⢲⢴⢶⣰⣲⣴⣶


Try it online! Link includes test cases. Explanation: Unfortunately there doesn't seem to be a good way to encode the destination characters as their codes jump all over the place. I looked into shifting the codes into the ASCII range to do the transliteration but that looks as if it will take 239 bytes.

# Scala 3, 48 bytes

Port of @loopy walt's Python answer in Scala.

c=>{val d=c.toInt;(d+d%64+14*(d&36)%192).toChar}


Attempt This Online!

# 05AB1E, 7 bytes

bœŽp÷èC


Port of @hyper-neutrino♦'s Jelly answer, so make sure to upvote that answer as well!

I/O as codepoint integers.

No TIO, since it's way too slow (it'll get a list of all binary-permutations and indexes into it).

Much faster version which does finish - 11 (or 9) bytes:

†: Should have been 9 bytes without the ƶ and Ā, but apparently there is a bug with the $$\n^{th}\$$ permutation builtin .I and bit-lists..

2вƶŽp÷.IĀ2β


I/O as codepoint integers.

Explanation:

b            # Convert the (implicit) input-integer to a binary-string
œ           # Get all permutations of this binary-string
Žp÷        # Push compressed integer 13251
è       # Index it into the list of permutations
C      # Convert this permuted binary-string back to a (base-10) integer
# (which is output implicitly as result)

2в           # Convert the (implicit) input-integer to a binary-list
ƶ          # Multiply each 1 to its 1-based index (bug workaround part 1 of 2)
Žp÷       # Push compressed integer 13251
.I     # Get the 0-based 13251st permutation of the list
Ā    # Convert each positive integer back to 1s (bug workaround part 2 of 2)
2β  # Convert this permuted binary-list back to a (base-10) integer
# (which is output implicitly as result)


Note: .I only works with lists and not with strings.

See this 05AB1E tip of mine (section How to compress large integers?) to understand why Žp÷ is 13251.

# Java, 23 bytes

c->c+c%64+(c&36)*14%192


Another port of @loopyWalt's Python answer.
I/O as codepoint-integers.

Try it online.

With characters as I/O, it would be 1 byte longer:

c->c+=c%64+(c&36)*14%192


Try it online.

Explanation (of the character I/O lambda function):

c->                 // Method with character as both parameter and return-type
c+=               //  Add to the current codepoint-integer, without changing its type:
c%64           //   The input-codepoint modulo-64
+              //   As well as:
(c&36)        //    The input-codepoint basewise-AND with 36
*14     //    Then multiplied by 14
%192 //    And then modulo-192
`