14
\$\begingroup\$

The Corpus are a fictional faction from the popular video game Warframe who have a somewhat interesting language.

Whilst other factions in the game such as the Grineer have some logic behind their language, the Corpus is simply a lossy substitution of the English language.

All Corpus words are the same as their English counterparts, except with the following alphabetical mappings:

English to Corpus mapping

This causes some problems with pronunciation as:

yes becomes yey
say becomes yay
yay becomes yay
sassy becomes yayyy
case becomes yaye

Here's a text version of the mappings:

a -> a
b -> t
c -> y
d -> p
e -> e
f -> t
g -> j
h -> k
i -> i
j -> t
k -> k
l -> p
m -> s
n -> t
o -> o
p -> k
q -> r
r -> t
s -> y
t -> p
u -> u
v -> t
w -> j
x -> k
y -> y
z -> b

The challenge

Given text using the English alphabet, output its Corpus translation.

For example, the text Hello, World! becomes Keppo, Jotpp! in Corpus

The Rules

  • Input will only consist of ASCII printable characters
  • Input text may contain whitespace and punctuation, these must be preserved
  • Capitalization of letters must be preserved
  • This is so naturally, fewest bytes wins!

The Testcases

Test cases are separated with <===========>, with a blank line between input and expected output

Hello, World!

Keppo, Jotpp!
<===========>
Yes

Yey
<===========>
TestcaSe

PeypyaYe
<===========>
Programming Puzzles and Code Golf

Ktojtassitj Kubbpey atp Yope Jopt
<===========>
This text has a
newline in it

Pkiy pekp kay a
tejpite it ip
<===========>
Corpus language best language

Yotkuy patjuaje teyp patjuaje
<===========>
Strip the flesh! Salt the wounds!

Yptik pke tpeyk! Yapp pke joutpy!
<===========>
"Install Warframe" they said, "It'll be fun" they said

"Itypapp Jatttase" pkey yaip, "Ip'pp te tut" pkey yaip
<===========>
What the **** did you just ****ing say about me, you little *****?
I'll have you know I graduated top of my class in the Navy Seals,
and I've been involved in numerous secret raids on Al-Quaeda,
and I have over 300 confirmed kills.

Jkap pke **** pip you tuyp ****itj yay atoup se, you pipppe *****?
I'pp kate you ktoj I jtapuapep pok ot sy ypayy it pke Taty Yeapy,
atp I'te teet ittoptep it tusetouy yeytep taipy ot Ap-Ruaepa,
atp I kate otet 300 yottitsep kippy.

The Bonus

If you also include an audio recording (or video with audio) of you pronouncing each of the testcase's Corpus translations, you may multiply your bytecount by 1 as a reward.

\$\endgroup\$
  • \$\begingroup\$ @Shaggy Sure, shoulda thought of that \$\endgroup\$ – Skidsdev Dec 20 '18 at 19:25
  • 4
    \$\begingroup\$ @RobertS. it also provides no bonus to your score (x * 1 == x). It's a tongue-in-cheek poke at the unpronouncability of many of the translations \$\endgroup\$ – Skidsdev Dec 20 '18 at 19:38
  • 1
    \$\begingroup\$ Can output be an array of characters? \$\endgroup\$ – ElPedro Dec 20 '18 at 21:23
  • \$\begingroup\$ @Skidsdev The "translations" are pronounceable; either as a recorded human voice or programmatically using machine learning and/or text-to-speech technologies. \$\endgroup\$ – guest271314 Dec 20 '18 at 22:19
  • 1
    \$\begingroup\$ And so was born the Finnish language! \$\endgroup\$ – sergiol Dec 26 '18 at 21:43

22 Answers 22

8
\$\begingroup\$

Bash + coreutils, 46

tr b-zB-Z ${a=typetjkitkpstokrtyputjkyb}${a^^}

Try it online!

\$\endgroup\$
4
\$\begingroup\$

05AB1E, 24 bytes

ži.•ÜÁ©;«ìñä°ÔG·ÖYΘ•Du«‡

Explanation:

                       ‡   transliterate
ži                         a-zA-Z with
  .•ÜÁ©;«ìñä°ÔG·ÖYΘ•       atypetjkitkpstokrtyputjkyb
                    Du«    concatenated with itself, uppercased

Try it online!

\$\endgroup\$
4
\$\begingroup\$

Charcoal, 42 bytes

≔”$⌊∧T-¶I^F⁷ü@n⁹γ›7η”η⭆θ⎇№β↧ι§⎇№βι↧ηη⌕β↧ιι

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

≔                       Assign
 ”$⌊∧T-¶I^F⁷ü@n⁹γ›7η”  Compressed string `ATYPETJKITKPSTOKRTYPUTJKYB` 
                     η  To variable

 θ                      Input string
⭆                       Map over characters and join
  ⎇                     If
    β                   Lowercase alphabet
   №                    Contains
      ι                 Current character
     ↧                  Lowercased
                        (Then)
        ⎇               If
          β             Lowercase alphabet
         №              Contains
           ι            Current character
                        (Then)
             η          Variable
            ↧           Lowercased
                        (Else)
              η         Variable
       §                Indexed by
               ⌕        Index of
                  ι     Current character
                 ↧      Lowercased
                β       In lowercase alphabet
                        (Else)
                   ι    Current character
                        Implicitly print
\$\endgroup\$
4
\$\begingroup\$

T-SQL, 107 Bytes

SELECT TRANSLATE(v,'bcdfghjlmnpqrstvwxzBCDFGHJLMNPQRSTVWXZ',
                   'typtjktpstkrtyptjkbTYPTJKTPSTKRTYPTJKB')FROM t

Line break and indent are for readability only.

Uses the SQL 2017 function TRANSLATE for character replacement.

Unfortunately had to put (almost) the entire alphabet in there twice to maintain casing. There are probably better ways, maybe something that handles the t's as a group, but this worked for me.

Input is via a pre-existing table t with varchar column v, per our IO rules.

In this case the table must be created using a case-sensitive collation, either by running on a case-sensitive server, or by using the COLLATE keyword (not counted toward character total):

CREATE TABLE t(v varchar(999) COLLATE Latin1_General_CS_AS)
\$\endgroup\$
3
\$\begingroup\$

JavaScript (Node.js), 100 bytes

s=>s.replace(/[a-z]/gi,c=>(C='_atypetjkitkpstokrtyputjkyb'[Buffer(c)[0]&31],c>{}?C:C.toUpperCase()))

Try it online!

s =>                                  // s = input string
  s.replace(                          // replace in s ...
    /[a-z]/gi,                        // ... all letters, no matter the case
    c => (                            // for each letter c:
      C =                             //   pick a replacement letter C
        '_atypetjkitkpstokrtyputjkyb' //   from a 1-indexed lookup string
        [Buffer(c)[0] & 31],          //   using the 5 lowest bits of the ASCII code of c
      c > {} ?                        //   if the original letter was in lower case:
        C                             //     use the replacement letter as-is
      :                               //   else:
        C.toUpperCase()               //     convert it to upper case
    )                                 // 
  )                                   // end of replace()
\$\endgroup\$
3
\$\begingroup\$

R, 79 bytes

function(x)chartr("b-zB-Z",paste0(y<-"typetjkitkpstokrtyputjkyb",toupper(y)),x)

Try it online!

Only 3 bytes shorter than literally typing both lower- and uppercase replacement strings together...

R, 79 bytes

function(x,`[`=chartr)"B-Z"[toupper(y),"b-z"[y<-"typetjkitkpstokrtyputjkyb",x]]

Try it online!

Fancier code, same byte count.

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

Perl 5 -p, 54 bytes

eval"y/B-Zb-z/".uc($a=typetjkitkpstokrtyputjkyb)."$a/"

Try it online!

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

Ruby, 55 bytes

$_.tr!"b-zB-Z",(x="typetjkitkpstokrtyputjkyb")+x.upcase

Try it online!

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

J, 78 61 bytes

-17 bytes thanks to FrownyFrog!

rplc(u:,98 66+/i.25);"0(,toupper)@'typetjkitkpstokrtyputjkyb'

Try it online!

\$\endgroup\$
  • 2
    \$\begingroup\$ 61 \$\endgroup\$ – FrownyFrog Dec 21 '18 at 10:52
  • \$\begingroup\$ @FrownyFrog Thanks! In my J804 I can't use constants at the right-hand side. I need to upgrade :) My solution is ugly nevertheless.... \$\endgroup\$ – Galen Ivanov Dec 21 '18 at 11:27
2
\$\begingroup\$

C# (Visual C# Interactive Compiler), 151 83 bytes

n=>n.Select(a=>char.IsLetter(a)?(char)(" ATYPETJKITKPSTOKRTYPUTJKYB"[a%32]|a&32):a)

Try it online!

Saved a whopping 68 bytes thanks to Pietu1998!

\$\endgroup\$
  • \$\begingroup\$ You can get this down to 83 bytes by removing the range, combining the Selects and using bitwise operators for casing. \$\endgroup\$ – PurkkaKoodari Dec 21 '18 at 14:01
  • \$\begingroup\$ Thanks! Nice trick with the bit wise operators! \$\endgroup\$ – Embodiment of Ignorance Dec 21 '18 at 16:23
2
\$\begingroup\$

K (ngn/k), 87 63 61 60 59 bytes

f:{`c$x-a-@[!128;98+!25;:;0+"typetjkitkpstokrtyputjkyb"]a:_x}

Try it online!

{ } function with argument x

_ to lowercase

a: assign to a

!128 the list 0 1 2 ... 127

@[!128; indices ;:; values ] amend it by replacing the elements at indices with the given values

98+!25 the list 98 99 100 ... 122 which are the ascii codes for "bcd...z"

juxtaposition is indexing, so we use a (implicitly converted to integers) as indices in the amended list

x-a- subtract from a, then subtract form x; this restores upper/lowercase as in the original string

`c$ convert to characters

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

Retina 0.8.2, 59 bytes

[a-z]
 $&
T`l`L
T`L`ATYP\ETJKITKPST\OKRTYPUTJKYB
T`L `l_` .

Try it online! Link includes test cases. Explanation:

[a-z]
 $&

Prefix a non-ASCII character to each letter. (I tried to use a non-breaking space but Firefox might have changed it back to a regular space after copying and pasting.)

T`l`L

Uppercase all of the letters.

T`L`ATYP\ETJKITKPST\OKRTYPUTJKYB

Convert the letters to Corpus.

T`L `l_` .

Lowercase the letters after the non-ASCII character and delete the non-ASCII character.

Naïve solution is 63 bytes:

T`lL`aty\petjkitk\pst\okrty\putjkybATYP\ETJKITKPST\OKRTYPUTJKYB

Try it online! Link includes test cases.

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

Python 2, 115 bytes

lambda i:i.translate(''.join(a))
a=map(chr,range(256))
b='typetjkitkpstokrtyputjkyb'
a[66:91]=b.upper();a[98:123]=b

Try it online!

Adapted from @ElPedro's answer. This generates the replacement for every ascii character in the array a and then uses str.translate.

Can be brought to 113 bytes if returning an array of chars is acceptable:

lambda i:[a[ord(x)]for x in i]
a=map(chr,range(256))
b='typetjkitkpstokrtyputjkyb'
a[66:91]=b.upper();a[98:123]=b

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Took some thinking at this time of night to work out how it was doing it. It's been a long day! Nice solution. \$\endgroup\$ – ElPedro Dec 20 '18 at 23:38
1
\$\begingroup\$

Jelly, 29 bytes

“qḍỊYl4ḃ©ƭṄxḳ½Dy’ṃⱮØA,Øa¤⁺żẎy

Try it online!

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

Japt, 37 bytes

;®i`…ypetjkŠkp¡okrtyp©jkyb`pu)gCpu bZ

Try it online!

The above link includes most test cases, but I haven't been able to input the second to last one as a string because it contains both single and double quotes. Here is that test case, input as an array of characters instead.

Explanation:

;                                        #Set C to the lowercase alphabet
 ®                                       #For each character Z of the input:
                                   bZ    # Find its index in:
                               C         #  The lowercase alphabet
                                pu       #  Plus the uppercase alphabet
                                         #  (-1 if it is not a letter)
                              g          # And get the character at that index in:
   `…ypetjkŠkp¡okrtyp©jkyb`              #  Get the lowercase Corpus alphabet
                           pu)           #  Plus the uppercase Corpus alphabet
  i                                      #  Add Z at the end (index -1)
\$\endgroup\$
0
\$\begingroup\$

Python 2, 138 132 bytes

def f(i,a='bcdfghjlmnpqrstvwxz',b='typtjktpstkrtyptjkb'):a+=a.upper();b+=b.upper();return''.join((x,b[a.find(x)])[x in a]for x in i)

Try it online!

Actually shorter with a named function than with a lambda!

lambda version, 138 bytes

lambda i,a='bcdfghjlmnpqrstvwxzBCDFGHJLMNPQRSTVWXZ',b='typtjktpstkrtyptjkbTYPTJKTPSTKRTYPTJKB':''.join((x,b[a.find(x)])[x in a]for x in i)

Try it online!

131 125 if we are allowed to return an array of characters and have the join outside the function.

def f(i,a='bcdfghjlmnpqrstvwxz',b='typtjktpstkrtyptjkb'):a+=a.upper();b+=b.upper();return[(x,b[a.find(x)])[x in a]for x in i]

Try it online!

\$\endgroup\$
  • 1
    \$\begingroup\$ You can still use a lambda if you make a and b global variables \$\endgroup\$ – Black Owl Kai Dec 20 '18 at 22:58
  • \$\begingroup\$ @BlackOwlKai - Thanks. Have been playing with that idea but it's getting late. Maybe tomorrow :) \$\endgroup\$ – ElPedro Dec 20 '18 at 22:59
  • \$\begingroup\$ Got it down to 120/113 characters (TIO without the testcases, else the link would be too long for a comment) \$\endgroup\$ – Black Owl Kai Dec 20 '18 at 23:08
  • \$\begingroup\$ Beats mine and different enough for you to post as your own answer. I'll upvote :) \$\endgroup\$ – ElPedro Dec 20 '18 at 23:09
  • \$\begingroup\$ Feel free to steal my test cases as well. They took longer to type in than the code... \$\endgroup\$ – ElPedro Dec 20 '18 at 23:12
0
\$\begingroup\$

PHP, 100 bytes

Code

<?=strtr($argv[0],($u=bcdfghjklmnpqrstvwxyz).($f=strtoupper)($u),($v=typtjktkpstkrtyptjkyb).$f($v));

Try it online!

Explanation

# using the provided character mapping given on the question, as an array
strtr($argv[0],                                  # strtr for the string replacement
($u=bcdfghjklmnpqrstvwxyz).($f=strtoupper)($u),  # Taking onthe the keys for the first string
($v=typtjktkpstkrtyptjkyb).$f($v));              # Using the values for second string
 # In both Strings appending the upper version of each string.
\$\endgroup\$
0
\$\begingroup\$

Pyth, 35 Bytes

XQ.*m+r1dd[tG."byàHuH¯¹e?rJyfh

Try it!

Could probably use Left map or something to get rid of the two d's, but I couldn't figure out how.

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

Java, 211 Bytes

a->{String b="BCDFGHJLMNPQRSTVWXZbcdfghjlmnpqrstvwxz",c="TYPTJKTPSTKRTYPTJKBtyptjktpstkrtyptjkb";a.chars().map(x->{int z;return(z=b.indexOf(x))>-1?c.toCharArray()[z]:x;}).forEach(x->System.out.print((char)x));};

Try it online!

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

Pyth, 34 chars

J."byàHuH¯¹e?rJyfh"XXztGJrtG1rJ1

Try it online!

The string is a compressed version of "typetjkitkpstokrtyputjkyb". For some reason I cannot get Pyth to compress "atypetjkitkpstokrtyputjkyb" with the function

+++\.N++hSzeSzCi-RChSzCMz-hCeSzChSzN
even though it would probably save a byte or two as the two t's could be eliminated.

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

Tcl, 114 bytes

proc C s {string map [split {btcydpftgjhkjtlpmsntpkqrrtsytpvtwjxkzbBTCYDPFTGJHKJTLPMSNTPKQRRTSYTPVTWJXKZB} ""] $s}

Try it online!

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

Lua, 153 bytes

t="atypetjkitkpstokrtyputjkyb"for c in(...):gmatch"."do i=c:lower():byte()-96n=t:sub(i,i)io.write((i<0or i>26)and c or(c==c:upper()and n:upper()or n))end

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.