5
\$\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\$
2
  • \$\begingroup\$ Can we return a list of codepoints instead? \$\endgroup\$
    – Steffan
    Apr 26 at 20:16
  • \$\begingroup\$ @Steffan No, the output must be only be composed of the symbols given \$\endgroup\$
    – Saphereye
    Apr 27 at 12:01

11 Answers 11

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\$

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 at 9:49
  • \$\begingroup\$ -1 byte with R=re.sub \$\endgroup\$
    – MarcMush
    Apr 27 at 18:22
  • \$\begingroup\$ @MarcMush I could have sworn I tried that! But then, I can't count :/ \$\endgroup\$
    – loopy walt
    Apr 27 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\$
    – Steffan
    May 11 at 1:32
1
\$\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\$
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\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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