Skip to main content
added 391 characters in body
Source Link
ovs
  • 60.6k
  • 3
  • 47
  • 161

BQN, 30 28 bytesSBCS

{∾•Fmt¨×⊸/+˝(⥊𝕩-⌜"aA")=⌜↕26}

Run online!

↕26 Range from 0 to 25.
⥊𝕩-⌜"aA" Differences between each of the characters in the input and a or A.
=⌜ Equality table between those two vectors.
Sum the columns.
×⊸/ Keep the values with sign 1 (or: remove the zeros)
∾•Fmt¨ Convert each value to a string and join.

A slightly different approach using Bins Down at 29 bytes:

{∾•Fmt¨×⊸/»1↓/⁼27↕⊸⍋⥊𝕩-⌜"aA"}

Run online!

BQN, 30 28 bytesSBCS

{∾•Fmt¨×⊸/+˝(⥊𝕩-⌜"aA")=⌜↕26}

Run online!

↕26 Range from 0 to 25.
⥊𝕩-⌜"aA" Differences between each of the characters in the input and a or A.
=⌜ Equality table between those two vectors.
Sum the columns.
×⊸/ Keep the values with sign 1 (or: remove the zeros)
∾•Fmt¨ Convert each value to a string and join.

BQN, 30 28 bytesSBCS

{∾•Fmt¨×⊸/+˝(⥊𝕩-⌜"aA")=⌜↕26}

Run online!

↕26 Range from 0 to 25.
⥊𝕩-⌜"aA" Differences between each of the characters in the input and a or A.
=⌜ Equality table between those two vectors.
Sum the columns.
×⊸/ Keep the values with sign 1 (or: remove the zeros)
∾•Fmt¨ Convert each value to a string and join.

A slightly different approach using Bins Down at 29 bytes:

{∾•Fmt¨×⊸/»1↓/⁼27↕⊸⍋⥊𝕩-⌜"aA"}

Run online!

deleted 24 characters in body
Source Link
ovs
  • 60.6k
  • 3
  • 47
  • 161

BQN, 3030 28 bytesSBCS

{∾•Fmt¨×⊸/+˝(𝕩∾32+𝕩⥊𝕩-⌜"aA")=⌜'a'+↕26=⌜↕26}

Run online!Run online!

'a'+↕26↕26 The lettersRange from a0 to z25.
𝕩∾32+𝕩⥊𝕩-⌜"aA" The input string joined withDifferences between each of the characters in the input string where each codepoint is increased by 32and a or A.
=⌜ Equality table between those two stringsvectors.
Sum the columns.
×⊸/ Keep the values with sign 1 (or: remove the zeros)
∾•Fmt¨ Convert each value to a string and join.

BQN, 30 bytesSBCS

{∾•Fmt¨×⊸/+˝(𝕩∾32+𝕩)=⌜'a'+↕26}

Run online!

'a'+↕26 The letters from a to z.
𝕩∾32+𝕩 The input string joined with the input string where each codepoint is increased by 32.
=⌜ Equality table between those two strings.
Sum the columns.
×⊸/ Keep the values with sign 1 (or: remove the zeros)
∾•Fmt¨ Convert each value to a string and join.

BQN, 30 28 bytesSBCS

{∾•Fmt¨×⊸/+˝(⥊𝕩-⌜"aA")=⌜↕26}

Run online!

↕26 Range from 0 to 25.
⥊𝕩-⌜"aA" Differences between each of the characters in the input and a or A.
=⌜ Equality table between those two vectors.
Sum the columns.
×⊸/ Keep the values with sign 1 (or: remove the zeros)
∾•Fmt¨ Convert each value to a string and join.

Source Link
ovs
  • 60.6k
  • 3
  • 47
  • 161

BQN, 30 bytesSBCS

{∾•Fmt¨×⊸/+˝(𝕩∾32+𝕩)=⌜'a'+↕26}

Run online!

'a'+↕26 The letters from a to z.
𝕩∾32+𝕩 The input string joined with the input string where each codepoint is increased by 32.
=⌜ Equality table between those two strings.
Sum the columns.
×⊸/ Keep the values with sign 1 (or: remove the zeros)
∾•Fmt¨ Convert each value to a string and join.