6
\$\begingroup\$

This challenge has been divided into parts.
Your goal is to convert a sentence into a form of 'short-hand'

For Part 1 these are the rules

  1. Take in 1 word
  2. Remove all vowels(a,e,i,o,u), except the ones at the beginning and the end
  3. If a letter is repeated more than once consecutively, reduce it to only one (e.g. Hello -> Hlo)
  4. Create a function which converts the word into it's corresponding unicode characters based on above given rules, as given in the table
Letter Corresponding Unicode Character
A Λ
B L
C 𐍉
D
E
F
G T
H |
I
J )
K <
L (
M
N
O
P
Q
R \
S
T _
U
V
W ⌵ (same as V)
X X
Y ɥ
Z

Test Cases

English Word Substituted Word
A Λ
Quick ⩁𐍉<
Brown L\⌵ᑎ
Fox ⌽X
Jumps )ᨈ⊥⦵
Over ┼⌵\
The _|∟
Lazy (ᒣɥ
Dog ꙄT
Turtle _\_(∟
Of ┼⌽
Terror _\

As this is code-golf, shortest answer wins!

Part 2 has been posted here

\$\endgroup\$
3
  • \$\begingroup\$ Can we return a list of codepoints instead? \$\endgroup\$
    – naffetS
    Apr 26, 2022 at 20:16
  • \$\begingroup\$ @Steffan No, the output must be only be composed of the symbols given \$\endgroup\$
    – Saphereye
    Apr 27, 2022 at 12:01
  • \$\begingroup\$ Do pop => pp or p or either? \$\endgroup\$
    – l4m2
    Aug 12 at 8:39

15 Answers 15

2
\$\begingroup\$

Burlesque, 86 bytes

zzgn"aeiou"XX\\)**97?-"ΛL𐍉Ꙅ∟⌽T|⩗)<(ᨈᑎ┼⊥⩁\⦵_⋃⌵⌵Xɥᒣ"jsi

Try it online!

zz          # To lower case
gn          # Unique consecutives
"aeiou"XX   # Vowels as list
\\          # List diff
)**         # Map ord
97?-        # Conert to index into alphabet
"ΛL𐍉Ꙅ∟⌽T|⩗)<(ᨈᑎ┼⊥⩁\⦵_⋃⌵⌵Xɥᒣ" # SH as string
jsi         # Select indices from SH string
\$\endgroup\$
2
\$\begingroup\$

Retina 0.8.2, 99 bytes

T`L`l
\B[aeiou]\B

(.)\1+
$1
c
𐍉
T`l`Λ\L_Ꙅ∟⌽T|⩗)<(ᨈᑎ┼⊥⩁\\⦵\_⋃⌵⌵Xɥᒣ

Try it online! Link includes test cases. Explanation:

T`L`l

Change everything to lower case.

\B[aeiou]\B

Remove all interior vowels.

(.)\1+
$1

Deduplicate consecutive letters.

c
𐍉

Convert c separately because T can only transliterate characters in the BMP.

T`l`Λ\L_Ꙅ∟⌽T|⩗)<(ᨈᑎ┼⊥⩁\\⦵\_⋃⌵⌵Xɥᒣ

Transliterate the remaining letters.

\$\endgroup\$
2
\$\begingroup\$

Factor + grouping.extras, 178 bytes

[ >lower 1 cut 1 short cut* swap "aeiou"without glue [ ] group-by values [ members ] map-concat [ 97 mod "ΛL𐍉Ꙅ∟⌽T|⩗)<(ᨈᑎ┼⊥⩁\\⦵_⋃⌵⌵Xɥᒣ"nth ] map ]

Try it online!

  • >lower Convert to lowercase
  • 1 cut 1 short cut* swap Slice the ends off the input (if possible -- that's what short is for) and bring the middle to the top of the stack.
  • "aeiou"without glue Remove vowels and put the ends back on.
  • [ ] group-by values [ members ] map-concat Consolidate consecutive letters.
  • [ 97 mod "ΛL𐍉Ꙅ∟⌽T|⩗)<(ᨈᑎ┼⊥⩁\\⦵_⋃⌵⌵Xɥᒣ"nth ] map Map letters to shorthand characters.
\$\endgroup\$
2
\$\begingroup\$

05AB1E, 76 bytes

lā¨Ć≠ÅÏžMм}ÔA•6Eˆ2O:¹VÑX©₃Œl±È“v¬BŒŠ>'µ‰‡S“úÁò›ØIÝZÚþв¬èôÏ&Áθ#›¤mн•Ž‚d·вç‡

Should have been 74 bytes without the , but apparently there's a bug in ÅÏ.. :/

Try it online or verify all test cases.

Explanation:

l          # Convert the (implicit) input-string to lowercase
 ā         # Push a list in the range [1,length] (without popping)
  ¨        # Remove the last item to make the range [1,length)
   Ć       # Enclose; append its own head, to have a trailing 1
    ≠      # Check which values are NOT 1
           # (we now have a list of 1s with leading/trailing 0 - e.g. [0,1,1,1,0])
     {À    # No-op bug-fix: sort the list, and rotate it once towards the left
     ÅÏ    # Apply to every truthy (==1) character in the string:
       žM  #  Push vowels-constant "aeoiu"
         м #  Remove those from the current character
      }Ô   # After the apply_on_truthy, connected uniquify the resulting string
A # Push the lowecase alphabet
 •6Eˆ2O:¹VÑX©₃Œl±È“v¬BŒŠ>'µ‰‡S“úÁò›ØIÝZÚþв¬èôÏ&Áθ#›¤mн•
          '# Push compressed integer 3279490039691721988310819230336479163628492048784374634744299180010706872685131111164709021133012715753321092552746940878765
   ނd     # Push compressed integer 33189
      ·    # Double it to 66378
           # (compressing 66378 directly is a byte longer: •15Γ•)
       в   # Convert the large integer to base-66378 as list:
           #  [923,76,66377,42564,8735,9021,84,124,10839,41,60,40,6664,5198,9532,8869,10817,92,10677,95,8899,9013,9013,88,613,5283]
        ç  # Convert each integer to a character with that codepoint
         ‡ # Transliterate the lowercase alphabet to these characters
           # (after which the result is output implicitly)

See this 05AB1E tip of mine (sections How to compress large integers? and How to compress integer lists?) to understand why •6Eˆ2O:¹VÑX©₃Œl±È“v¬BŒŠ>'µ‰‡S“úÁò›ØIÝZÚþв¬èôÏ&Áθ#›¤mн• is 3279490039691721988310819230336479163628492048784374634744299180010706872685131111164709021133012715753321092552746940878765; Ž‚d is 33189; •15Γ• is 66378 ; and •6Eˆ2O:¹VÑX©₃Œl±È“v¬BŒŠ>'µ‰‡S“úÁò›ØIÝZÚþв¬èôÏ&Áθ#›¤mн•Ž‚d·в is [923,76,66377,42564,8735,9021,84,124,10839,41,60,40,6664,5198,9532,8869,10817,92,10677,95,8899,9013,9013,88,613,5283].

\$\endgroup\$
2
\$\begingroup\$

Python 3.8 (pre-release), 151 bytes

lambda s:R(r"(.)\1+",r"\1",R("\B[AEIUO]\B","",s.upper())).translate(4*'ᑎ┼⊥⩁\⦵_⋃⌵⌵XɥᒣΛL𐍉Ꙅ∟⌽T|⩗)<(ᨈ')
import re
R=re.sub

Try it online!

-2 thanks to @MarcMush. -1 thanks to @Steffan Test harness borrowed from @solid.py

\$\endgroup\$
4
  • \$\begingroup\$ @solid.py It's more or less the same trick as here. There is a pretty detailed explanation in one of the comments. \$\endgroup\$
    – loopy walt
    Apr 27, 2022 at 9:49
  • \$\begingroup\$ -1 byte with R=re.sub \$\endgroup\$
    – MarcMush
    Apr 27, 2022 at 18:22
  • \$\begingroup\$ @MarcMush I could have sworn I tried that! But then, I can't count :/ \$\endgroup\$
    – loopy walt
    Apr 27, 2022 at 19:04
  • 1
    \$\begingroup\$ you actually don't need the r in r"\B[AEIUO]\B". backslashes are automatically escaped when followed by a letter \$\endgroup\$
    – naffetS
    May 11, 2022 at 1:32
1
\$\begingroup\$

Perl 5, 103 bytes

Pretty standard approach: lowercase the input, remove the inner vowels, remove duplicated chars and transliterate a-z to the required chars.

$_=lc;s/\B[aeiou]\B//g;s/(.)\1+/$1/g;y;a-z;ΛL𐍉Ꙅ∟⌽T|⩗)<(ᨈᑎ┼⊥⩁\\⦵_⋃⌵⌵Xɥᒣ

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Python 3, 180 bytes

lambda w:''.join('ΛL𐍉Ꙅ∟⌽T|⩗)<(ᨈᑎ┼⊥⩁\⦵_⋃⌵⌵Xɥᒣ'[ord(c)%97]for c in(w[0]+re.sub(r'(.)\1+|[aeiou]','',w[1:-1])+(w[-1],'')[len(w)<2]).lower())
import re

Try it online!

\$\endgroup\$
0
1
\$\begingroup\$

Julia 1.0, 138 bytes

~=replace
!s=(lowercase(s)~r"\B[aeiou]\B"=>"")~r"(.)\1*"=>x->["ΛL𐍉Ꙅ∟⌽T|⩗)<(ᨈᑎ┼⊥⩁\\⦵_⋃⌵⌵Xɥᒣ"...][x[1]-'`']

Try it online!

Just found out that ~ has the same precedence than assignement (with right associativity so the parenthesis are needed), making it the only operator with lower precendence than =>

\$\endgroup\$
1
\$\begingroup\$

Vyxal, 80 bytes

ɽ:ẏḢṪṪ‡kvF¨MĠvhṅka»⟇†←¬ʁoĊ ∇"₄[ḃ0εẆḭ:₇°ḃτsf≈β→ƈḭ⅛Ṁǒṡ□ø꘍$↲„I₇⊍ǔ¹eṀHbṡ‛1L»»ƛ∨O»τCĿ

Try it Online!

Port of 05AB1E answer.

How?

ɽ:ẏḢṪṪ‡kvF¨MĠvhṅka»⟇†←¬ʁoĊ ∇"₄[ḃ0εẆḭ:₇°ḃτsf≈β→ƈḭ⅛Ṁǒṡ□ø꘍$↲„I₇⊍ǔ¹eṀHbṡ‛1L»»ƛ∨O»τCĿ
ɽ                                                                                 # Lowercase the (implicit) input
 :                                                                                # Duplicate
  ẏ                                                                               # Get length range [0, length)
   ḢṪṪ                                                                            # Remove the first item and the last two items
      ‡kvF                                                                        # Two element lambda: Remove all vowels from input to lambda
          ¨M                                                                      # Apply z (the lambda) for each element of x (the lowercased input)
                                                                                  #   only at the indices in y (the length range without the first and last two items)
            Ġ                                                                     # Group consecutive identical items
             vh                                                                   # Get the first item of each (this is removing consecutive duplicates)
               ṅ                                                                  # Join by nothing
                ka                                                                # Push the lowercase alphabet
                  »⟇†←¬ʁoĊ ∇"₄[ḃ0εẆḭ:₇°ḃτsf≈β→ƈḭ⅛Ṁǒṡ□ø꘍$↲„I₇⊍ǔ¹eṀHbṡ‛1L»          # Push huge compressed integer 3279490039691721988310819230336479163628492048784374634744299180010706872685131111164709021133012715753321092552746940878765
                                                                        »ƛ∨O»     # Push compressed integer 66378
                                                                             τ    # Convert the huge compressed integer to base-66378:
                                                                                  #  [923,76,66377,42564,8735,9021,84,124,10839,41,60,40,6664,5198,9532,8869,10817,92,10677,95,8899,9013,9013,88,613,5283]
                                                                              C   # Convert that list of codepoints to their corresponding characters
                                                                               ‡  # Transliterate the string made earlier from the lowercase alphabet to these characters
\$\endgroup\$
0
\$\begingroup\$

JavaScript (Node.js), 143 bytes

s=>s.replace(/\B[aeiou]\B|(.)(?=\1)|(.)/gi,(a,b,c)=>c?[..."_ΛL𐍉Ꙅ∟⌽T|⩗)<(ᨈᑎ┼⊥⩁\\⦵_⋃⌵⌵Xɥᒣ"][Buffer(c)[0]%32]:'')

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Ruby -pl, 103 bytes

gsub(/\B[aeiou]\B/,"").tr_s!"A-Za-z","ΛL𐍉Ꙅ∟⌽T|⩗)<(ᨈᑎ┼⊥⩁\\\\⦵_⋃⌵⌵Xɥᒣ"*2

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Charcoal, 99 bytes

≔Φ↧θ¬∧∧κ⁻⊕κLθ№aeiouιθ⭆Φθ¬∧κ⁼ι§θ⊖κyΛL𐍉Ꙅ∟⌽T|⩗)<(ᨈᑎ┼⊥⩁\⦵_⋃⌵⌵Xɥᒣ⌕βι

Try it online! Link is to verbose version of code. Note that the deverbosifier thinks that the embedded string needs to be quoted (at a cost of three bytes) but I disagree. Explanation:

≔Φ↧θ¬∧∧κ⁻⊕κLθ№aeiouιθ⭆Φθ

Lowercase the string and remove interior vowels.

¬∧κ⁼ι§θ⊖κyΛL𐍉Ꙅ∟⌽T|⩗)<(ᨈᑎ┼⊥⩁\⦵_⋃⌵⌵Xɥᒣ⌕βι

Deduplicate consecutive letters and translate from lowercase letters to the desired symbols. Note that the symbols take up 3 or 4 bytes each (I'm relying on the deverbosifier calculation here, as it doesn't actually bother generating the appropriate byte sequences).

\$\endgroup\$
0
\$\begingroup\$

Haskell, 200 bytes

import Data.Char
import Data.List
c[h]=[h]
c(h:t)=h:[c|c<-init t,notElem c"AEIOU"]++[last t]
f=map((cycle"ᑎ┼⊥⩁\\⦵_⋃⌵⌵XɥᒣΛL𐍉Ꙅ∟⌽T|⩗)<(ᨈ"!!).ord.head).group.c.map toUpper

Attempt This Online!

\$\endgroup\$
0
\$\begingroup\$

POSIX Issue ≤7 Shell + Utilities, 111 characters

tr a-z A-Z|sed 's/./&\
/;s/.$/\
&/'|tr A-Z 'ΛL𐍉Ꙅ∟⌽T|⩗)<(ᨈᑎ┼⊥⩁\\⦵_⋃⌵⌵Xɥᒣ/'|sed 2s/[Λ∟⩗┼⋃ɥ]//g|tr -d \\n|tr -cs 0

Fun fact: since XPG3, tr is defined in terms of characters, and is defined exclusively for characters all the way until SUSv3, which renames -c to -C and adds byte-wise -c.
This is why in present-day POSIX we observe -c which renders the first set the complement of specified values and -C — characters, as well as stuff like [=equivalence classes=] which IIRC is only vaguely supported by the illumos gate? This is a wide-reaching standards blunder. The status of this in Issue 8 and later is unclear.

Not surprisingly, nothing supports this. All implementations behave as-if the data were in the POSIX (C) locale, i.e. they operate on bytes.

For something actual implementations accept, substitute the third line for

&/;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/ΛL𐍉Ꙅ∟⌽T|⩗)<(ᨈᑎ┼⊥⩁\\⦵_⋃⌵⌵Xɥᒣ/'|sed 2s/[Λ∟⩗┼⋃ɥ]//g|tr -d \\n|tr -cs 0

this is what the transcript below uses to emulate the answer, but it's also obviously much longer.

$ for w in A Quick Brown Fox Jumps Over The Lazy Dog Turtle Of Terror; do echo $w | ./cg; echo; done
Λ
⩁𐍉<
L\⌵ᑎ
⌽X
)ᨈ⊥⦵
┼⌵\
_|∟
(ᒣɥ
ꙄT
_\_(∟
┼⌽
_\
\$\endgroup\$
0
\$\begingroup\$

Go, 289 bytes

import."strings"
func f(s string)(O string){o,S:="",ToUpper(s)
for i:=range S{r,L:=S[i:i+1],len(o)
if L>0&&o[L-1:L]==r{continue}
if!Contains("AEIOU",r)||i<1||i>len(s)-2{o+=r}}
for _,r:=range o{O+=string([]rune(`ΛL𐍉Ꙅ∟⌽T|⩗)<(ᨈᑎ┼⊥⩁\⦵_⋃⌵⌵Xɥᒣ`)[r-'A'])}
return}

Attempt This Online!

Golang, once again, doesn't have the luxury of regexp lookaheads, lookbehinds, and backreferences, forcing a "manual" implementation. If you can find a Golang-compatible regexp that solved this challenge, leave a comment.

A regexp-using solution using \B[AEIOU]\B is 10 bytes longer than this solution.

Explanation

// required import
import."strings"
func f(s string)(O string){
// setup
o,S:="",ToUpper(s)
// for each char...
for i:=range S{
// get the current char
r:=S[i:i+1]
// if it's a duplicate char, ignore
if len(o)>0&&o[len(o)-1:len(o)]==r{continue}
// if it's not a vowel, or it's a vowel not at the start/end of the string, add it in
if !Contains("AEIOU",r)||i<1||i>len(s)-2{o+=r}}
// translate to the unicode chars
for _,r:=range o{O+=string([]rune(`ΛL𐍉Ꙅ∟⌽T|⩗)<(ᨈᑎ┼⊥⩁\⦵_⋃⌵⌵Xɥᒣ`)[r-'A'])}
return}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.