The Improved Caesar Pig Latin Cypher
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
The problem with the caesar cypher is the resulting words are often unpronounceable. The problem with pig latin is that it is easy to decode. Why not combine them?
Input
A word consisting of the 26 english letters.
Output
First, change every consonant in the word to the next consonant in the alphabet. So, b goes to c, d goes to f, and z goes to b. Then, change every vowel to the next vowel in the alphabet (u goes to a). Last, only if the first letter of the word is a consonant, move that letter to the end of the word and add "ay" to the end of the word.
Examples:
cat outputs evday
dog outputs uhfay
eel outputs iim
This is code golf, so the shortest code wins.
Case does not matter. Vowels are A, E, I, O, and U
code-golf
New contributor
add a comment |Â
up vote
4
down vote
favorite
The problem with the caesar cypher is the resulting words are often unpronounceable. The problem with pig latin is that it is easy to decode. Why not combine them?
Input
A word consisting of the 26 english letters.
Output
First, change every consonant in the word to the next consonant in the alphabet. So, b goes to c, d goes to f, and z goes to b. Then, change every vowel to the next vowel in the alphabet (u goes to a). Last, only if the first letter of the word is a consonant, move that letter to the end of the word and add "ay" to the end of the word.
Examples:
cat outputs evday
dog outputs uhfay
eel outputs iim
This is code golf, so the shortest code wins.
Case does not matter. Vowels are A, E, I, O, and U
code-golf
New contributor
will we have capital letters in the input?
â Jo King
36 mins ago
1
no, but you can if you want
â qazwsx
34 mins ago
1
Welcome to PPCG! Very nice challenge, clearly presented.
â Jonathan Allan
30 mins ago
Suggested test case:z â bay
â Arnauld
21 mins ago
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
The problem with the caesar cypher is the resulting words are often unpronounceable. The problem with pig latin is that it is easy to decode. Why not combine them?
Input
A word consisting of the 26 english letters.
Output
First, change every consonant in the word to the next consonant in the alphabet. So, b goes to c, d goes to f, and z goes to b. Then, change every vowel to the next vowel in the alphabet (u goes to a). Last, only if the first letter of the word is a consonant, move that letter to the end of the word and add "ay" to the end of the word.
Examples:
cat outputs evday
dog outputs uhfay
eel outputs iim
This is code golf, so the shortest code wins.
Case does not matter. Vowels are A, E, I, O, and U
code-golf
New contributor
The problem with the caesar cypher is the resulting words are often unpronounceable. The problem with pig latin is that it is easy to decode. Why not combine them?
Input
A word consisting of the 26 english letters.
Output
First, change every consonant in the word to the next consonant in the alphabet. So, b goes to c, d goes to f, and z goes to b. Then, change every vowel to the next vowel in the alphabet (u goes to a). Last, only if the first letter of the word is a consonant, move that letter to the end of the word and add "ay" to the end of the word.
Examples:
cat outputs evday
dog outputs uhfay
eel outputs iim
This is code golf, so the shortest code wins.
Case does not matter. Vowels are A, E, I, O, and U
code-golf
code-golf
New contributor
New contributor
edited 1 hour ago
New contributor
asked 2 hours ago
qazwsx
213
213
New contributor
New contributor
will we have capital letters in the input?
â Jo King
36 mins ago
1
no, but you can if you want
â qazwsx
34 mins ago
1
Welcome to PPCG! Very nice challenge, clearly presented.
â Jonathan Allan
30 mins ago
Suggested test case:z â bay
â Arnauld
21 mins ago
add a comment |Â
will we have capital letters in the input?
â Jo King
36 mins ago
1
no, but you can if you want
â qazwsx
34 mins ago
1
Welcome to PPCG! Very nice challenge, clearly presented.
â Jonathan Allan
30 mins ago
Suggested test case:z â bay
â Arnauld
21 mins ago
will we have capital letters in the input?
â Jo King
36 mins ago
will we have capital letters in the input?
â Jo King
36 mins ago
1
1
no, but you can if you want
â qazwsx
34 mins ago
no, but you can if you want
â qazwsx
34 mins ago
1
1
Welcome to PPCG! Very nice challenge, clearly presented.
â Jonathan Allan
30 mins ago
Welcome to PPCG! Very nice challenge, clearly presented.
â Jonathan Allan
30 mins ago
Suggested test case:
z â bay
â Arnauld
21 mins ago
Suggested test case:
z â bay
â Arnauld
21 mins ago
add a comment |Â
4 Answers
4
active
oldest
votes
up vote
1
down vote
05AB1E, 21 bytes
Ã
¾MDÃÂâ¡Ã
¾NDÃÂâ¡ìÃ
¾NsÃÂ¥iÃÂâ¦ÿay
Try it online!
Explanation
Ã
¾MDÃÂâ¡ # replace each vowel with the next vowel in the alphabet
Ã
¾NDÃÂâ¡ # replace each consonant with the next consonant in the alphabet
ìÃ
¾NsÃÂ¥i # if the first letter is a consonant
ÃÂâ¦ÿay # rotate the word left and add "ay"
Dof zua iwis jies vji vsehifz ug Desvj Pmehaiot Tji Woti? I vjuahjv puv. Iv't puv e tvusz vji Jifo xuamf vimm zua. Iv't e Sovj mihipf.
â qazwsx
55 mins ago
add a comment |Â
up vote
1
down vote
JavaScript (Node.js), 121 bytes
Expects the input string in lower case.
s=>(v=n=>2130466>>n&1)((a=Buffer(s).map(n=>(i=v(n),g=n=>n++%61?v(n)^i?g(n):n:g(96))(n)))[0],a+='')?a:a.slice(1)+a[0]+'ay'
Try it online!
add a comment |Â
up vote
1
down vote
R, 101 bytes
The simple way. Now slightly less obvious.
function(s)sub("^([^aeiou])(.*)","\2\1ay",chartr(intToUtf8(97:122),"ecdfighjoklmnpuqrstvawxyzb",s))
Try it online!
add a comment |Â
up vote
1
down vote
Jelly, 25 bytes
,á¹ÂÃÂ¥1y
ÃÂẹçÃÂá¸Âçá¹ÂḢeÃÂá¸ÂÃÂéîâÂÂayâÂÂx
Try it online!
What am I doing? Honestly I'm questioning my sanity (really, éî
?!), this is a sneaky and probably trivial-to-outgolf solution! Only works as a full program because it's too strange... Will try to bring it to normal soon.
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
05AB1E, 21 bytes
Ã
¾MDÃÂâ¡Ã
¾NDÃÂâ¡ìÃ
¾NsÃÂ¥iÃÂâ¦ÿay
Try it online!
Explanation
Ã
¾MDÃÂâ¡ # replace each vowel with the next vowel in the alphabet
Ã
¾NDÃÂâ¡ # replace each consonant with the next consonant in the alphabet
ìÃ
¾NsÃÂ¥i # if the first letter is a consonant
ÃÂâ¦ÿay # rotate the word left and add "ay"
Dof zua iwis jies vji vsehifz ug Desvj Pmehaiot Tji Woti? I vjuahjv puv. Iv't puv e tvusz vji Jifo xuamf vimm zua. Iv't e Sovj mihipf.
â qazwsx
55 mins ago
add a comment |Â
up vote
1
down vote
05AB1E, 21 bytes
Ã
¾MDÃÂâ¡Ã
¾NDÃÂâ¡ìÃ
¾NsÃÂ¥iÃÂâ¦ÿay
Try it online!
Explanation
Ã
¾MDÃÂâ¡ # replace each vowel with the next vowel in the alphabet
Ã
¾NDÃÂâ¡ # replace each consonant with the next consonant in the alphabet
ìÃ
¾NsÃÂ¥i # if the first letter is a consonant
ÃÂâ¦ÿay # rotate the word left and add "ay"
Dof zua iwis jies vji vsehifz ug Desvj Pmehaiot Tji Woti? I vjuahjv puv. Iv't puv e tvusz vji Jifo xuamf vimm zua. Iv't e Sovj mihipf.
â qazwsx
55 mins ago
add a comment |Â
up vote
1
down vote
up vote
1
down vote
05AB1E, 21 bytes
Ã
¾MDÃÂâ¡Ã
¾NDÃÂâ¡ìÃ
¾NsÃÂ¥iÃÂâ¦ÿay
Try it online!
Explanation
Ã
¾MDÃÂâ¡ # replace each vowel with the next vowel in the alphabet
Ã
¾NDÃÂâ¡ # replace each consonant with the next consonant in the alphabet
ìÃ
¾NsÃÂ¥i # if the first letter is a consonant
ÃÂâ¦ÿay # rotate the word left and add "ay"
05AB1E, 21 bytes
Ã
¾MDÃÂâ¡Ã
¾NDÃÂâ¡ìÃ
¾NsÃÂ¥iÃÂâ¦ÿay
Try it online!
Explanation
Ã
¾MDÃÂâ¡ # replace each vowel with the next vowel in the alphabet
Ã
¾NDÃÂâ¡ # replace each consonant with the next consonant in the alphabet
ìÃ
¾NsÃÂ¥i # if the first letter is a consonant
ÃÂâ¦ÿay # rotate the word left and add "ay"
answered 1 hour ago
Emigna
43k431131
43k431131
Dof zua iwis jies vji vsehifz ug Desvj Pmehaiot Tji Woti? I vjuahjv puv. Iv't puv e tvusz vji Jifo xuamf vimm zua. Iv't e Sovj mihipf.
â qazwsx
55 mins ago
add a comment |Â
Dof zua iwis jies vji vsehifz ug Desvj Pmehaiot Tji Woti? I vjuahjv puv. Iv't puv e tvusz vji Jifo xuamf vimm zua. Iv't e Sovj mihipf.
â qazwsx
55 mins ago
Dof zua iwis jies vji vsehifz ug Desvj Pmehaiot Tji Woti? I vjuahjv puv. Iv't puv e tvusz vji Jifo xuamf vimm zua. Iv't e Sovj mihipf.
â qazwsx
55 mins ago
Dof zua iwis jies vji vsehifz ug Desvj Pmehaiot Tji Woti? I vjuahjv puv. Iv't puv e tvusz vji Jifo xuamf vimm zua. Iv't e Sovj mihipf.
â qazwsx
55 mins ago
add a comment |Â
up vote
1
down vote
JavaScript (Node.js), 121 bytes
Expects the input string in lower case.
s=>(v=n=>2130466>>n&1)((a=Buffer(s).map(n=>(i=v(n),g=n=>n++%61?v(n)^i?g(n):n:g(96))(n)))[0],a+='')?a:a.slice(1)+a[0]+'ay'
Try it online!
add a comment |Â
up vote
1
down vote
JavaScript (Node.js), 121 bytes
Expects the input string in lower case.
s=>(v=n=>2130466>>n&1)((a=Buffer(s).map(n=>(i=v(n),g=n=>n++%61?v(n)^i?g(n):n:g(96))(n)))[0],a+='')?a:a.slice(1)+a[0]+'ay'
Try it online!
add a comment |Â
up vote
1
down vote
up vote
1
down vote
JavaScript (Node.js), 121 bytes
Expects the input string in lower case.
s=>(v=n=>2130466>>n&1)((a=Buffer(s).map(n=>(i=v(n),g=n=>n++%61?v(n)^i?g(n):n:g(96))(n)))[0],a+='')?a:a.slice(1)+a[0]+'ay'
Try it online!
JavaScript (Node.js), 121 bytes
Expects the input string in lower case.
s=>(v=n=>2130466>>n&1)((a=Buffer(s).map(n=>(i=v(n),g=n=>n++%61?v(n)^i?g(n):n:g(96))(n)))[0],a+='')?a:a.slice(1)+a[0]+'ay'
Try it online!
answered 20 mins ago
Arnauld
64.2k580270
64.2k580270
add a comment |Â
add a comment |Â
up vote
1
down vote
R, 101 bytes
The simple way. Now slightly less obvious.
function(s)sub("^([^aeiou])(.*)","\2\1ay",chartr(intToUtf8(97:122),"ecdfighjoklmnpuqrstvawxyzb",s))
Try it online!
add a comment |Â
up vote
1
down vote
R, 101 bytes
The simple way. Now slightly less obvious.
function(s)sub("^([^aeiou])(.*)","\2\1ay",chartr(intToUtf8(97:122),"ecdfighjoklmnpuqrstvawxyzb",s))
Try it online!
add a comment |Â
up vote
1
down vote
up vote
1
down vote
R, 101 bytes
The simple way. Now slightly less obvious.
function(s)sub("^([^aeiou])(.*)","\2\1ay",chartr(intToUtf8(97:122),"ecdfighjoklmnpuqrstvawxyzb",s))
Try it online!
R, 101 bytes
The simple way. Now slightly less obvious.
function(s)sub("^([^aeiou])(.*)","\2\1ay",chartr(intToUtf8(97:122),"ecdfighjoklmnpuqrstvawxyzb",s))
Try it online!
edited 2 mins ago
answered 50 mins ago
J.Doe
7219
7219
add a comment |Â
add a comment |Â
up vote
1
down vote
Jelly, 25 bytes
,á¹ÂÃÂ¥1y
ÃÂẹçÃÂá¸Âçá¹ÂḢeÃÂá¸ÂÃÂéîâÂÂayâÂÂx
Try it online!
What am I doing? Honestly I'm questioning my sanity (really, éî
?!), this is a sneaky and probably trivial-to-outgolf solution! Only works as a full program because it's too strange... Will try to bring it to normal soon.
add a comment |Â
up vote
1
down vote
Jelly, 25 bytes
,á¹ÂÃÂ¥1y
ÃÂẹçÃÂá¸Âçá¹ÂḢeÃÂá¸ÂÃÂéîâÂÂayâÂÂx
Try it online!
What am I doing? Honestly I'm questioning my sanity (really, éî
?!), this is a sneaky and probably trivial-to-outgolf solution! Only works as a full program because it's too strange... Will try to bring it to normal soon.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Jelly, 25 bytes
,á¹ÂÃÂ¥1y
ÃÂẹçÃÂá¸Âçá¹ÂḢeÃÂá¸ÂÃÂéîâÂÂayâÂÂx
Try it online!
What am I doing? Honestly I'm questioning my sanity (really, éî
?!), this is a sneaky and probably trivial-to-outgolf solution! Only works as a full program because it's too strange... Will try to bring it to normal soon.
Jelly, 25 bytes
,á¹ÂÃÂ¥1y
ÃÂẹçÃÂá¸Âçá¹ÂḢeÃÂá¸ÂÃÂéîâÂÂayâÂÂx
Try it online!
What am I doing? Honestly I'm questioning my sanity (really, éî
?!), this is a sneaky and probably trivial-to-outgolf solution! Only works as a full program because it's too strange... Will try to bring it to normal soon.
answered 1 min ago
Mr. Xcoder
30.4k758193
30.4k758193
add a comment |Â
add a comment |Â
qazwsx is a new contributor. Be nice, and check out our Code of Conduct.
qazwsx is a new contributor. Be nice, and check out our Code of Conduct.
qazwsx is a new contributor. Be nice, and check out our Code of Conduct.
qazwsx is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f172281%2fthe-improved-caesar-pig-latin-cypher%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
will we have capital letters in the input?
â Jo King
36 mins ago
1
no, but you can if you want
â qazwsx
34 mins ago
1
Welcome to PPCG! Very nice challenge, clearly presented.
â Jonathan Allan
30 mins ago
Suggested test case:
z â bay
â Arnauld
21 mins ago