The Improved Caesar Pig Latin Cipher

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
15
down vote

favorite












The problem with the Caesar cipher 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 -> evday 
dog -> uhfay
eel -> iim


  • This is code-golf, so the shortest code wins.

  • Case does not matter.

  • Vowels that will be used are A, E, I, O, and U









share|improve this question









New contributor




qazwsx is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • will we have capital letters in the input?
    – Jo King
    16 hours ago






  • 2




    no, but you can if you want
    – qazwsx
    16 hours ago






  • 5




    Welcome to PPCG! Very nice challenge, clearly presented.
    – Jonathan Allan
    15 hours ago






  • 1




    Suggested test case: z → bay
    – Arnauld
    15 hours ago










  • jot ot e wisz opvisitvoph dupdiqv cav o fu puv vjopl ov jimqt xovj vji ecomovz vu qsupuapdi vji xusftvay
    – Shadow
    8 hours ago















up vote
15
down vote

favorite












The problem with the Caesar cipher 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 -> evday 
dog -> uhfay
eel -> iim


  • This is code-golf, so the shortest code wins.

  • Case does not matter.

  • Vowels that will be used are A, E, I, O, and U









share|improve this question









New contributor




qazwsx is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • will we have capital letters in the input?
    – Jo King
    16 hours ago






  • 2




    no, but you can if you want
    – qazwsx
    16 hours ago






  • 5




    Welcome to PPCG! Very nice challenge, clearly presented.
    – Jonathan Allan
    15 hours ago






  • 1




    Suggested test case: z → bay
    – Arnauld
    15 hours ago










  • jot ot e wisz opvisitvoph dupdiqv cav o fu puv vjopl ov jimqt xovj vji ecomovz vu qsupuapdi vji xusftvay
    – Shadow
    8 hours ago













up vote
15
down vote

favorite









up vote
15
down vote

favorite











The problem with the Caesar cipher 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 -> evday 
dog -> uhfay
eel -> iim


  • This is code-golf, so the shortest code wins.

  • Case does not matter.

  • Vowels that will be used are A, E, I, O, and U









share|improve this question









New contributor




qazwsx is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











The problem with the Caesar cipher 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 -> evday 
dog -> uhfay
eel -> iim


  • This is code-golf, so the shortest code wins.

  • Case does not matter.

  • Vowels that will be used are A, E, I, O, and U






code-golf string cipher






share|improve this question









New contributor




qazwsx is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




qazwsx is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 27 mins ago









u_ndefined

2918




2918






New contributor




qazwsx is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 17 hours ago









qazwsx

764




764




New contributor




qazwsx is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





qazwsx is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






qazwsx is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • will we have capital letters in the input?
    – Jo King
    16 hours ago






  • 2




    no, but you can if you want
    – qazwsx
    16 hours ago






  • 5




    Welcome to PPCG! Very nice challenge, clearly presented.
    – Jonathan Allan
    15 hours ago






  • 1




    Suggested test case: z → bay
    – Arnauld
    15 hours ago










  • jot ot e wisz opvisitvoph dupdiqv cav o fu puv vjopl ov jimqt xovj vji ecomovz vu qsupuapdi vji xusftvay
    – Shadow
    8 hours ago

















  • will we have capital letters in the input?
    – Jo King
    16 hours ago






  • 2




    no, but you can if you want
    – qazwsx
    16 hours ago






  • 5




    Welcome to PPCG! Very nice challenge, clearly presented.
    – Jonathan Allan
    15 hours ago






  • 1




    Suggested test case: z → bay
    – Arnauld
    15 hours ago










  • jot ot e wisz opvisitvoph dupdiqv cav o fu puv vjopl ov jimqt xovj vji ecomovz vu qsupuapdi vji xusftvay
    – Shadow
    8 hours ago
















will we have capital letters in the input?
– Jo King
16 hours ago




will we have capital letters in the input?
– Jo King
16 hours ago




2




2




no, but you can if you want
– qazwsx
16 hours ago




no, but you can if you want
– qazwsx
16 hours ago




5




5




Welcome to PPCG! Very nice challenge, clearly presented.
– Jonathan Allan
15 hours ago




Welcome to PPCG! Very nice challenge, clearly presented.
– Jonathan Allan
15 hours ago




1




1




Suggested test case: z → bay
– Arnauld
15 hours ago




Suggested test case: z → bay
– Arnauld
15 hours ago












jot ot e wisz opvisitvoph dupdiqv cav o fu puv vjopl ov jimqt xovj vji ecomovz vu qsupuapdi vji xusftvay
– Shadow
8 hours ago





jot ot e wisz opvisitvoph dupdiqv cav o fu puv vjopl ov jimqt xovj vji ecomovz vu qsupuapdi vji xusftvay
– Shadow
8 hours ago











10 Answers
10






active

oldest

votes

















up vote
3
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"





share|improve this answer
















  • 1




    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
    16 hours ago










  • @qazwsx "Did you ever hear the tragedy of Darth Plagueis The Wise? I thought not. It's not a story the Jedi would tell you. It's a Sith legend."
    – Kevin Cruijssen
    6 hours ago

















up vote
3
down vote














R, 86 bytes



Simple way. chartr has the charming and useful property that it can specify letter ranges, which save a few bytes.





function(s)sub("^([^aeiou])(.*)","\2\1ay",chartr("a-z","ecdfighjok-npuq-tvaw-zb",s))


Try it online!






share|improve this answer





























    up vote
    2
    down vote














    JavaScript (Node.js), 121 116 bytes



    Expects the input string in lower case.





    s=>(v=n=>2130466>>n&1)((a=Buffer(s).map(n=>(g=i=>v(n=n%61?n+1:97)^i?g(i):n)(v(n))))[0],a+='')?a:a.slice(1)+a[0]+'ay'


    Try it online!






    share|improve this answer





























      up vote
      2
      down vote














      Retina 0.8.2, 50 bytes



      T`uo`aeioub-df-hj-np-tv-zb
      ^([^aeiou])(.*)
      $2$1ay


      Try it online! Link includes test cases. Similar approach to the R answer. Explanation:



      T`uo`aeioub-df-hj-np-tv-zb


      o refers to the other set, i.e. aeioub-df-hj-np-tv-zb, which expands to aeioubcdfghjlkmnpqrstvwxyzb, so uo expands to uaeioubcdfghjlkmnpqrstvwxyzb. This results in the following transliteration:



      uaeioubcdfghjlkmnpqrstvwxyzb
      aeioubcdfghjlkmnpqrstvwxyzb


      The second u and b are ignored as they can never be matched, so this provides the desired cipher. (Note that in Retina 1 you can of course use v instead of aeiou for a 5 byte saving.)



      ^([^aeiou])(.*)
      $2$1ay


      If the first letter is not a vowel, rotate it to the end and suffix ay.






      share|improve this answer



























        up vote
        2
        down vote














        Python 2, 153 121 110 99 bytes





        lambda s:''.join('ecdfighjoklmnpuqrstvawxyzb'[ord(c)-97]for c in[s[1:]+s[0]+'ux',s][s[0]in'aeiou'])


        Try it online!






        share|improve this answer





























          up vote
          1
          down vote














          Jelly, 24 bytes



          ,ṙ¥1y
          ØẹçØḄçṙḢe©ØḄƊ®⁾ayx


          Try it online!



          Saved 1 byte thanks to Jonathan Allan (use the two-char syntax rather than quotes).






          share|improve this answer






















          • Unfortunately far longer sane, non-sneaky version (1-byte shorter sneaky equivalent). I won't be able to update this within the next few hours, but do point out if you find improvements.
            – Mr. Xcoder
            15 hours ago











          • Use ⁾ay for a byte. The © could go after the e since that is what you are storing. I have Øáº¹Øá¸„,żṙ€¥1ẎyṙḢe©Øá¸„ÆŠ®â¾ayẋ.
            – Jonathan Allan
            11 hours ago

















          up vote
          1
          down vote














          Java (JDK 10), 175 bytes





          s->String r="",a="aeiouabcdfghjklmnpqrstvwxyzb";char c=s.charAt(0);if(a.indexOf(c)>5)s=s.substring(1)+c+"ux";for(char d:s.toCharArray())r+=a.charAt(a.indexOf(d)+1);return r;


          Try it online!






          share|improve this answer



























            up vote
            1
            down vote














            ><>, 94 bytes



            i:0(?v84*%
            2%?!v~r:5g
            37r}<vr*46*
            ol?!;>4g
            ecdfighjoklmnpuqrstvawxyzb
            1 1 1 1 1


            Try it online!






            share|improve this answer





























              up vote
              1
              down vote














              Ruby, 96 69 bytes





              ->s/^[^aeiou]/=~(r=s.tr'zb-yadehinotu','b-zefijopuva')?$'+$&+'ay':r


              Try it online!



              Fun fact of the day: tr() matches strings right-to-left. I always assumed it was left-to-right.






              share|improve this answer





























                up vote
                0
                down vote














                Red, 149 bytes



                func[s][c:"aeioua.bcdfghjklmnpqrstvwxyzb"t: copy""foreach p s[append t c/(1
                + index? find c p)]if 7 < index? find c t/1[move t tail t append t"ay"]t]


                Try it online!



                As (almost) always, the longest entry






                share|improve this answer




















                  Your Answer




                  StackExchange.ifUsing("editor", function ()
                  return StackExchange.using("mathjaxEditing", function ()
                  StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
                  StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
                  );
                  );
                  , "mathjax-editing");

                  StackExchange.ifUsing("editor", function ()
                  StackExchange.using("externalEditor", function ()
                  StackExchange.using("snippets", function ()
                  StackExchange.snippets.init();
                  );
                  );
                  , "code-snippets");

                  StackExchange.ready(function()
                  var channelOptions =
                  tags: "".split(" "),
                  id: "200"
                  ;
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function()
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled)
                  StackExchange.using("snippets", function()
                  createEditor();
                  );

                  else
                  createEditor();

                  );

                  function createEditor()
                  StackExchange.prepareEditor(
                  heartbeatType: 'answer',
                  convertImagesToLinks: false,
                  noModals: false,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: null,
                  bindNavPrevention: true,
                  postfix: "",
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  );



                  );






                  qazwsx is a new contributor. Be nice, and check out our Code of Conduct.









                   

                  draft saved


                  draft discarded


















                  StackExchange.ready(
                  function ()
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f172281%2fthe-improved-caesar-pig-latin-cipher%23new-answer', 'question_page');

                  );

                  Post as a guest






























                  10 Answers
                  10






                  active

                  oldest

                  votes








                  10 Answers
                  10






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes








                  up vote
                  3
                  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"





                  share|improve this answer
















                  • 1




                    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
                    16 hours ago










                  • @qazwsx "Did you ever hear the tragedy of Darth Plagueis The Wise? I thought not. It's not a story the Jedi would tell you. It's a Sith legend."
                    – Kevin Cruijssen
                    6 hours ago














                  up vote
                  3
                  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"





                  share|improve this answer
















                  • 1




                    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
                    16 hours ago










                  • @qazwsx "Did you ever hear the tragedy of Darth Plagueis The Wise? I thought not. It's not a story the Jedi would tell you. It's a Sith legend."
                    – Kevin Cruijssen
                    6 hours ago












                  up vote
                  3
                  down vote










                  up vote
                  3
                  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"





                  share|improve this answer













                  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"






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 16 hours ago









                  Emigna

                  43.1k431131




                  43.1k431131







                  • 1




                    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
                    16 hours ago










                  • @qazwsx "Did you ever hear the tragedy of Darth Plagueis The Wise? I thought not. It's not a story the Jedi would tell you. It's a Sith legend."
                    – Kevin Cruijssen
                    6 hours ago












                  • 1




                    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
                    16 hours ago










                  • @qazwsx "Did you ever hear the tragedy of Darth Plagueis The Wise? I thought not. It's not a story the Jedi would tell you. It's a Sith legend."
                    – Kevin Cruijssen
                    6 hours ago







                  1




                  1




                  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
                  16 hours 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
                  16 hours ago












                  @qazwsx "Did you ever hear the tragedy of Darth Plagueis The Wise? I thought not. It's not a story the Jedi would tell you. It's a Sith legend."
                  – Kevin Cruijssen
                  6 hours ago




                  @qazwsx "Did you ever hear the tragedy of Darth Plagueis The Wise? I thought not. It's not a story the Jedi would tell you. It's a Sith legend."
                  – Kevin Cruijssen
                  6 hours ago










                  up vote
                  3
                  down vote














                  R, 86 bytes



                  Simple way. chartr has the charming and useful property that it can specify letter ranges, which save a few bytes.





                  function(s)sub("^([^aeiou])(.*)","\2\1ay",chartr("a-z","ecdfighjok-npuq-tvaw-zb",s))


                  Try it online!






                  share|improve this answer


























                    up vote
                    3
                    down vote














                    R, 86 bytes



                    Simple way. chartr has the charming and useful property that it can specify letter ranges, which save a few bytes.





                    function(s)sub("^([^aeiou])(.*)","\2\1ay",chartr("a-z","ecdfighjok-npuq-tvaw-zb",s))


                    Try it online!






                    share|improve this answer
























                      up vote
                      3
                      down vote










                      up vote
                      3
                      down vote










                      R, 86 bytes



                      Simple way. chartr has the charming and useful property that it can specify letter ranges, which save a few bytes.





                      function(s)sub("^([^aeiou])(.*)","\2\1ay",chartr("a-z","ecdfighjok-npuq-tvaw-zb",s))


                      Try it online!






                      share|improve this answer















                      R, 86 bytes



                      Simple way. chartr has the charming and useful property that it can specify letter ranges, which save a few bytes.





                      function(s)sub("^([^aeiou])(.*)","\2\1ay",chartr("a-z","ecdfighjok-npuq-tvaw-zb",s))


                      Try it online!







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 14 hours ago

























                      answered 16 hours ago









                      J.Doe

                      7419




                      7419




















                          up vote
                          2
                          down vote














                          JavaScript (Node.js), 121 116 bytes



                          Expects the input string in lower case.





                          s=>(v=n=>2130466>>n&1)((a=Buffer(s).map(n=>(g=i=>v(n=n%61?n+1:97)^i?g(i):n)(v(n))))[0],a+='')?a:a.slice(1)+a[0]+'ay'


                          Try it online!






                          share|improve this answer


























                            up vote
                            2
                            down vote














                            JavaScript (Node.js), 121 116 bytes



                            Expects the input string in lower case.





                            s=>(v=n=>2130466>>n&1)((a=Buffer(s).map(n=>(g=i=>v(n=n%61?n+1:97)^i?g(i):n)(v(n))))[0],a+='')?a:a.slice(1)+a[0]+'ay'


                            Try it online!






                            share|improve this answer
























                              up vote
                              2
                              down vote










                              up vote
                              2
                              down vote










                              JavaScript (Node.js), 121 116 bytes



                              Expects the input string in lower case.





                              s=>(v=n=>2130466>>n&1)((a=Buffer(s).map(n=>(g=i=>v(n=n%61?n+1:97)^i?g(i):n)(v(n))))[0],a+='')?a:a.slice(1)+a[0]+'ay'


                              Try it online!






                              share|improve this answer















                              JavaScript (Node.js), 121 116 bytes



                              Expects the input string in lower case.





                              s=>(v=n=>2130466>>n&1)((a=Buffer(s).map(n=>(g=i=>v(n=n%61?n+1:97)^i?g(i):n)(v(n))))[0],a+='')?a:a.slice(1)+a[0]+'ay'


                              Try it online!







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited 14 hours ago

























                              answered 15 hours ago









                              Arnauld

                              64.2k580270




                              64.2k580270




















                                  up vote
                                  2
                                  down vote














                                  Retina 0.8.2, 50 bytes



                                  T`uo`aeioub-df-hj-np-tv-zb
                                  ^([^aeiou])(.*)
                                  $2$1ay


                                  Try it online! Link includes test cases. Similar approach to the R answer. Explanation:



                                  T`uo`aeioub-df-hj-np-tv-zb


                                  o refers to the other set, i.e. aeioub-df-hj-np-tv-zb, which expands to aeioubcdfghjlkmnpqrstvwxyzb, so uo expands to uaeioubcdfghjlkmnpqrstvwxyzb. This results in the following transliteration:



                                  uaeioubcdfghjlkmnpqrstvwxyzb
                                  aeioubcdfghjlkmnpqrstvwxyzb


                                  The second u and b are ignored as they can never be matched, so this provides the desired cipher. (Note that in Retina 1 you can of course use v instead of aeiou for a 5 byte saving.)



                                  ^([^aeiou])(.*)
                                  $2$1ay


                                  If the first letter is not a vowel, rotate it to the end and suffix ay.






                                  share|improve this answer
























                                    up vote
                                    2
                                    down vote














                                    Retina 0.8.2, 50 bytes



                                    T`uo`aeioub-df-hj-np-tv-zb
                                    ^([^aeiou])(.*)
                                    $2$1ay


                                    Try it online! Link includes test cases. Similar approach to the R answer. Explanation:



                                    T`uo`aeioub-df-hj-np-tv-zb


                                    o refers to the other set, i.e. aeioub-df-hj-np-tv-zb, which expands to aeioubcdfghjlkmnpqrstvwxyzb, so uo expands to uaeioubcdfghjlkmnpqrstvwxyzb. This results in the following transliteration:



                                    uaeioubcdfghjlkmnpqrstvwxyzb
                                    aeioubcdfghjlkmnpqrstvwxyzb


                                    The second u and b are ignored as they can never be matched, so this provides the desired cipher. (Note that in Retina 1 you can of course use v instead of aeiou for a 5 byte saving.)



                                    ^([^aeiou])(.*)
                                    $2$1ay


                                    If the first letter is not a vowel, rotate it to the end and suffix ay.






                                    share|improve this answer






















                                      up vote
                                      2
                                      down vote










                                      up vote
                                      2
                                      down vote










                                      Retina 0.8.2, 50 bytes



                                      T`uo`aeioub-df-hj-np-tv-zb
                                      ^([^aeiou])(.*)
                                      $2$1ay


                                      Try it online! Link includes test cases. Similar approach to the R answer. Explanation:



                                      T`uo`aeioub-df-hj-np-tv-zb


                                      o refers to the other set, i.e. aeioub-df-hj-np-tv-zb, which expands to aeioubcdfghjlkmnpqrstvwxyzb, so uo expands to uaeioubcdfghjlkmnpqrstvwxyzb. This results in the following transliteration:



                                      uaeioubcdfghjlkmnpqrstvwxyzb
                                      aeioubcdfghjlkmnpqrstvwxyzb


                                      The second u and b are ignored as they can never be matched, so this provides the desired cipher. (Note that in Retina 1 you can of course use v instead of aeiou for a 5 byte saving.)



                                      ^([^aeiou])(.*)
                                      $2$1ay


                                      If the first letter is not a vowel, rotate it to the end and suffix ay.






                                      share|improve this answer













                                      Retina 0.8.2, 50 bytes



                                      T`uo`aeioub-df-hj-np-tv-zb
                                      ^([^aeiou])(.*)
                                      $2$1ay


                                      Try it online! Link includes test cases. Similar approach to the R answer. Explanation:



                                      T`uo`aeioub-df-hj-np-tv-zb


                                      o refers to the other set, i.e. aeioub-df-hj-np-tv-zb, which expands to aeioubcdfghjlkmnpqrstvwxyzb, so uo expands to uaeioubcdfghjlkmnpqrstvwxyzb. This results in the following transliteration:



                                      uaeioubcdfghjlkmnpqrstvwxyzb
                                      aeioubcdfghjlkmnpqrstvwxyzb


                                      The second u and b are ignored as they can never be matched, so this provides the desired cipher. (Note that in Retina 1 you can of course use v instead of aeiou for a 5 byte saving.)



                                      ^([^aeiou])(.*)
                                      $2$1ay


                                      If the first letter is not a vowel, rotate it to the end and suffix ay.







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered 12 hours ago









                                      Neil

                                      75.3k744170




                                      75.3k744170




















                                          up vote
                                          2
                                          down vote














                                          Python 2, 153 121 110 99 bytes





                                          lambda s:''.join('ecdfighjoklmnpuqrstvawxyzb'[ord(c)-97]for c in[s[1:]+s[0]+'ux',s][s[0]in'aeiou'])


                                          Try it online!






                                          share|improve this answer


























                                            up vote
                                            2
                                            down vote














                                            Python 2, 153 121 110 99 bytes





                                            lambda s:''.join('ecdfighjoklmnpuqrstvawxyzb'[ord(c)-97]for c in[s[1:]+s[0]+'ux',s][s[0]in'aeiou'])


                                            Try it online!






                                            share|improve this answer
























                                              up vote
                                              2
                                              down vote










                                              up vote
                                              2
                                              down vote










                                              Python 2, 153 121 110 99 bytes





                                              lambda s:''.join('ecdfighjoklmnpuqrstvawxyzb'[ord(c)-97]for c in[s[1:]+s[0]+'ux',s][s[0]in'aeiou'])


                                              Try it online!






                                              share|improve this answer















                                              Python 2, 153 121 110 99 bytes





                                              lambda s:''.join('ecdfighjoklmnpuqrstvawxyzb'[ord(c)-97]for c in[s[1:]+s[0]+'ux',s][s[0]in'aeiou'])


                                              Try it online!







                                              share|improve this answer














                                              share|improve this answer



                                              share|improve this answer








                                              edited 10 hours ago

























                                              answered 15 hours ago









                                              Chas Brown

                                              4,2261319




                                              4,2261319




















                                                  up vote
                                                  1
                                                  down vote














                                                  Jelly, 24 bytes



                                                  ,ṙ¥1y
                                                  ØẹçØḄçṙḢe©ØḄƊ®⁾ayx


                                                  Try it online!



                                                  Saved 1 byte thanks to Jonathan Allan (use the two-char syntax rather than quotes).






                                                  share|improve this answer






















                                                  • Unfortunately far longer sane, non-sneaky version (1-byte shorter sneaky equivalent). I won't be able to update this within the next few hours, but do point out if you find improvements.
                                                    – Mr. Xcoder
                                                    15 hours ago











                                                  • Use ⁾ay for a byte. The © could go after the e since that is what you are storing. I have Øáº¹Øá¸„,żṙ€¥1ẎyṙḢe©Øá¸„ÆŠ®â¾ayẋ.
                                                    – Jonathan Allan
                                                    11 hours ago














                                                  up vote
                                                  1
                                                  down vote














                                                  Jelly, 24 bytes



                                                  ,ṙ¥1y
                                                  ØẹçØḄçṙḢe©ØḄƊ®⁾ayx


                                                  Try it online!



                                                  Saved 1 byte thanks to Jonathan Allan (use the two-char syntax rather than quotes).






                                                  share|improve this answer






















                                                  • Unfortunately far longer sane, non-sneaky version (1-byte shorter sneaky equivalent). I won't be able to update this within the next few hours, but do point out if you find improvements.
                                                    – Mr. Xcoder
                                                    15 hours ago











                                                  • Use ⁾ay for a byte. The © could go after the e since that is what you are storing. I have Øáº¹Øá¸„,żṙ€¥1ẎyṙḢe©Øá¸„ÆŠ®â¾ayẋ.
                                                    – Jonathan Allan
                                                    11 hours ago












                                                  up vote
                                                  1
                                                  down vote










                                                  up vote
                                                  1
                                                  down vote










                                                  Jelly, 24 bytes



                                                  ,ṙ¥1y
                                                  ØẹçØḄçṙḢe©ØḄƊ®⁾ayx


                                                  Try it online!



                                                  Saved 1 byte thanks to Jonathan Allan (use the two-char syntax rather than quotes).






                                                  share|improve this answer















                                                  Jelly, 24 bytes



                                                  ,ṙ¥1y
                                                  ØẹçØḄçṙḢe©ØḄƊ®⁾ayx


                                                  Try it online!



                                                  Saved 1 byte thanks to Jonathan Allan (use the two-char syntax rather than quotes).







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited 5 hours ago

























                                                  answered 15 hours ago









                                                  Mr. Xcoder

                                                  30.4k758193




                                                  30.4k758193











                                                  • Unfortunately far longer sane, non-sneaky version (1-byte shorter sneaky equivalent). I won't be able to update this within the next few hours, but do point out if you find improvements.
                                                    – Mr. Xcoder
                                                    15 hours ago











                                                  • Use ⁾ay for a byte. The © could go after the e since that is what you are storing. I have Øáº¹Øá¸„,żṙ€¥1ẎyṙḢe©Øá¸„ÆŠ®â¾ayẋ.
                                                    – Jonathan Allan
                                                    11 hours ago
















                                                  • Unfortunately far longer sane, non-sneaky version (1-byte shorter sneaky equivalent). I won't be able to update this within the next few hours, but do point out if you find improvements.
                                                    – Mr. Xcoder
                                                    15 hours ago











                                                  • Use ⁾ay for a byte. The © could go after the e since that is what you are storing. I have Øáº¹Øá¸„,żṙ€¥1ẎyṙḢe©Øá¸„ÆŠ®â¾ayẋ.
                                                    – Jonathan Allan
                                                    11 hours ago















                                                  Unfortunately far longer sane, non-sneaky version (1-byte shorter sneaky equivalent). I won't be able to update this within the next few hours, but do point out if you find improvements.
                                                  – Mr. Xcoder
                                                  15 hours ago





                                                  Unfortunately far longer sane, non-sneaky version (1-byte shorter sneaky equivalent). I won't be able to update this within the next few hours, but do point out if you find improvements.
                                                  – Mr. Xcoder
                                                  15 hours ago













                                                  Use ⁾ay for a byte. The © could go after the e since that is what you are storing. I have Øáº¹Øá¸„,żṙ€¥1ẎyṙḢe©Øá¸„ÆŠ®â¾ayẋ.
                                                  – Jonathan Allan
                                                  11 hours ago




                                                  Use ⁾ay for a byte. The © could go after the e since that is what you are storing. I have Øáº¹Øá¸„,żṙ€¥1ẎyṙḢe©Øá¸„ÆŠ®â¾ayẋ.
                                                  – Jonathan Allan
                                                  11 hours ago










                                                  up vote
                                                  1
                                                  down vote














                                                  Java (JDK 10), 175 bytes





                                                  s->String r="",a="aeiouabcdfghjklmnpqrstvwxyzb";char c=s.charAt(0);if(a.indexOf(c)>5)s=s.substring(1)+c+"ux";for(char d:s.toCharArray())r+=a.charAt(a.indexOf(d)+1);return r;


                                                  Try it online!






                                                  share|improve this answer
























                                                    up vote
                                                    1
                                                    down vote














                                                    Java (JDK 10), 175 bytes





                                                    s->String r="",a="aeiouabcdfghjklmnpqrstvwxyzb";char c=s.charAt(0);if(a.indexOf(c)>5)s=s.substring(1)+c+"ux";for(char d:s.toCharArray())r+=a.charAt(a.indexOf(d)+1);return r;


                                                    Try it online!






                                                    share|improve this answer






















                                                      up vote
                                                      1
                                                      down vote










                                                      up vote
                                                      1
                                                      down vote










                                                      Java (JDK 10), 175 bytes





                                                      s->String r="",a="aeiouabcdfghjklmnpqrstvwxyzb";char c=s.charAt(0);if(a.indexOf(c)>5)s=s.substring(1)+c+"ux";for(char d:s.toCharArray())r+=a.charAt(a.indexOf(d)+1);return r;


                                                      Try it online!






                                                      share|improve this answer













                                                      Java (JDK 10), 175 bytes





                                                      s->String r="",a="aeiouabcdfghjklmnpqrstvwxyzb";char c=s.charAt(0);if(a.indexOf(c)>5)s=s.substring(1)+c+"ux";for(char d:s.toCharArray())r+=a.charAt(a.indexOf(d)+1);return r;


                                                      Try it online!







                                                      share|improve this answer












                                                      share|improve this answer



                                                      share|improve this answer










                                                      answered 4 hours ago









                                                      Olivier Grégoire

                                                      7,63111741




                                                      7,63111741




















                                                          up vote
                                                          1
                                                          down vote














                                                          ><>, 94 bytes



                                                          i:0(?v84*%
                                                          2%?!v~r:5g
                                                          37r}<vr*46*
                                                          ol?!;>4g
                                                          ecdfighjoklmnpuqrstvawxyzb
                                                          1 1 1 1 1


                                                          Try it online!






                                                          share|improve this answer


























                                                            up vote
                                                            1
                                                            down vote














                                                            ><>, 94 bytes



                                                            i:0(?v84*%
                                                            2%?!v~r:5g
                                                            37r}<vr*46*
                                                            ol?!;>4g
                                                            ecdfighjoklmnpuqrstvawxyzb
                                                            1 1 1 1 1


                                                            Try it online!






                                                            share|improve this answer
























                                                              up vote
                                                              1
                                                              down vote










                                                              up vote
                                                              1
                                                              down vote










                                                              ><>, 94 bytes



                                                              i:0(?v84*%
                                                              2%?!v~r:5g
                                                              37r}<vr*46*
                                                              ol?!;>4g
                                                              ecdfighjoklmnpuqrstvawxyzb
                                                              1 1 1 1 1


                                                              Try it online!






                                                              share|improve this answer















                                                              ><>, 94 bytes



                                                              i:0(?v84*%
                                                              2%?!v~r:5g
                                                              37r}<vr*46*
                                                              ol?!;>4g
                                                              ecdfighjoklmnpuqrstvawxyzb
                                                              1 1 1 1 1


                                                              Try it online!







                                                              share|improve this answer














                                                              share|improve this answer



                                                              share|improve this answer








                                                              edited 3 hours ago

























                                                              answered 3 hours ago









                                                              Sok

                                                              2,871722




                                                              2,871722




















                                                                  up vote
                                                                  1
                                                                  down vote














                                                                  Ruby, 96 69 bytes





                                                                  ->s/^[^aeiou]/=~(r=s.tr'zb-yadehinotu','b-zefijopuva')?$'+$&+'ay':r


                                                                  Try it online!



                                                                  Fun fact of the day: tr() matches strings right-to-left. I always assumed it was left-to-right.






                                                                  share|improve this answer


























                                                                    up vote
                                                                    1
                                                                    down vote














                                                                    Ruby, 96 69 bytes





                                                                    ->s/^[^aeiou]/=~(r=s.tr'zb-yadehinotu','b-zefijopuva')?$'+$&+'ay':r


                                                                    Try it online!



                                                                    Fun fact of the day: tr() matches strings right-to-left. I always assumed it was left-to-right.






                                                                    share|improve this answer
























                                                                      up vote
                                                                      1
                                                                      down vote










                                                                      up vote
                                                                      1
                                                                      down vote










                                                                      Ruby, 96 69 bytes





                                                                      ->s/^[^aeiou]/=~(r=s.tr'zb-yadehinotu','b-zefijopuva')?$'+$&+'ay':r


                                                                      Try it online!



                                                                      Fun fact of the day: tr() matches strings right-to-left. I always assumed it was left-to-right.






                                                                      share|improve this answer















                                                                      Ruby, 96 69 bytes





                                                                      ->s/^[^aeiou]/=~(r=s.tr'zb-yadehinotu','b-zefijopuva')?$'+$&+'ay':r


                                                                      Try it online!



                                                                      Fun fact of the day: tr() matches strings right-to-left. I always assumed it was left-to-right.







                                                                      share|improve this answer














                                                                      share|improve this answer



                                                                      share|improve this answer








                                                                      edited 1 hour ago

























                                                                      answered 1 hour ago









                                                                      G B

                                                                      6,4071324




                                                                      6,4071324




















                                                                          up vote
                                                                          0
                                                                          down vote














                                                                          Red, 149 bytes



                                                                          func[s][c:"aeioua.bcdfghjklmnpqrstvwxyzb"t: copy""foreach p s[append t c/(1
                                                                          + index? find c p)]if 7 < index? find c t/1[move t tail t append t"ay"]t]


                                                                          Try it online!



                                                                          As (almost) always, the longest entry






                                                                          share|improve this answer
























                                                                            up vote
                                                                            0
                                                                            down vote














                                                                            Red, 149 bytes



                                                                            func[s][c:"aeioua.bcdfghjklmnpqrstvwxyzb"t: copy""foreach p s[append t c/(1
                                                                            + index? find c p)]if 7 < index? find c t/1[move t tail t append t"ay"]t]


                                                                            Try it online!



                                                                            As (almost) always, the longest entry






                                                                            share|improve this answer






















                                                                              up vote
                                                                              0
                                                                              down vote










                                                                              up vote
                                                                              0
                                                                              down vote










                                                                              Red, 149 bytes



                                                                              func[s][c:"aeioua.bcdfghjklmnpqrstvwxyzb"t: copy""foreach p s[append t c/(1
                                                                              + index? find c p)]if 7 < index? find c t/1[move t tail t append t"ay"]t]


                                                                              Try it online!



                                                                              As (almost) always, the longest entry






                                                                              share|improve this answer













                                                                              Red, 149 bytes



                                                                              func[s][c:"aeioua.bcdfghjklmnpqrstvwxyzb"t: copy""foreach p s[append t c/(1
                                                                              + index? find c p)]if 7 < index? find c t/1[move t tail t append t"ay"]t]


                                                                              Try it online!



                                                                              As (almost) always, the longest entry







                                                                              share|improve this answer












                                                                              share|improve this answer



                                                                              share|improve this answer










                                                                              answered 4 hours ago









                                                                              Galen Ivanov

                                                                              4,7871829




                                                                              4,7871829




















                                                                                  qazwsx is a new contributor. Be nice, and check out our Code of Conduct.









                                                                                   

                                                                                  draft saved


                                                                                  draft discarded


















                                                                                  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.













                                                                                   


                                                                                  draft saved


                                                                                  draft discarded














                                                                                  StackExchange.ready(
                                                                                  function ()
                                                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f172281%2fthe-improved-caesar-pig-latin-cipher%23new-answer', 'question_page');

                                                                                  );

                                                                                  Post as a guest













































































                                                                                  Comments

                                                                                  Popular posts from this blog

                                                                                  What does second last employer means? [closed]

                                                                                  List of Gilmore Girls characters

                                                                                  Confectionery