Play Zip, Zap, Zop












7












$begingroup$


There's a little improv warm up game where you arrange yourselves in a circle and send zips, zaps, and zops around by pointing to a person and saying the next word in the sequence, then they do the same until all of you are warmed up or whatever.



Your task is to create a program that gives the next word in sequence given an input word. (Zip --> Zap --> Zop --> Zip) Since there's a lot of different ways to say these three words and flairs that can be added to them, your program should imitate case and letter duplication and carry suffixes.



To elaborate, your input will be one or more Zs, then one or more Is, As, or Os (all the same letter), then one or more Ps, (all letters up to this point may be in mixed case) followed by some arbitrary suffix (which may be empty). You should leave the runs of Zs and Ps, as well as the suffix exactly as received, but then change the Is to As, As to Os, or Os to Is, preserving case at each step.



Example Test Cases



zip         ==> zap
zAp ==> zOp
ZOP ==> ZIP
ZiiP ==> ZaaP
ZZaapp ==> ZZoopp
zzzzOoOPppP ==> zzzzIiIPppP
Zipperoni ==> Zapperoni
ZAPsky ==> ZOPsky
ZoPtOn ==> ZiPtOn
zipzip ==> zapzip
zapzopzip ==> zopzopzip
zoopzaap ==> ziipzaap


Rules and Notes




  • You may use any convenient character encoding for input and output, provided that it supports all printable ASCII characters, provided that it was created prior to this challenge.

  • You may assume the input word is some variant of Zip, Zap, or Zop. All other inputs result in undefined behavior.


    • Valid inputs will full-match the regex Z+(I+|A+|O+)P+.* (in mixed case)



  • You may assume that the input word consists entirely of ASCII letters.


Happy Golfing!










share|improve this question









$endgroup$

















    7












    $begingroup$


    There's a little improv warm up game where you arrange yourselves in a circle and send zips, zaps, and zops around by pointing to a person and saying the next word in the sequence, then they do the same until all of you are warmed up or whatever.



    Your task is to create a program that gives the next word in sequence given an input word. (Zip --> Zap --> Zop --> Zip) Since there's a lot of different ways to say these three words and flairs that can be added to them, your program should imitate case and letter duplication and carry suffixes.



    To elaborate, your input will be one or more Zs, then one or more Is, As, or Os (all the same letter), then one or more Ps, (all letters up to this point may be in mixed case) followed by some arbitrary suffix (which may be empty). You should leave the runs of Zs and Ps, as well as the suffix exactly as received, but then change the Is to As, As to Os, or Os to Is, preserving case at each step.



    Example Test Cases



    zip         ==> zap
    zAp ==> zOp
    ZOP ==> ZIP
    ZiiP ==> ZaaP
    ZZaapp ==> ZZoopp
    zzzzOoOPppP ==> zzzzIiIPppP
    Zipperoni ==> Zapperoni
    ZAPsky ==> ZOPsky
    ZoPtOn ==> ZiPtOn
    zipzip ==> zapzip
    zapzopzip ==> zopzopzip
    zoopzaap ==> ziipzaap


    Rules and Notes




    • You may use any convenient character encoding for input and output, provided that it supports all printable ASCII characters, provided that it was created prior to this challenge.

    • You may assume the input word is some variant of Zip, Zap, or Zop. All other inputs result in undefined behavior.


      • Valid inputs will full-match the regex Z+(I+|A+|O+)P+.* (in mixed case)



    • You may assume that the input word consists entirely of ASCII letters.


    Happy Golfing!










    share|improve this question









    $endgroup$















      7












      7








      7





      $begingroup$


      There's a little improv warm up game where you arrange yourselves in a circle and send zips, zaps, and zops around by pointing to a person and saying the next word in the sequence, then they do the same until all of you are warmed up or whatever.



      Your task is to create a program that gives the next word in sequence given an input word. (Zip --> Zap --> Zop --> Zip) Since there's a lot of different ways to say these three words and flairs that can be added to them, your program should imitate case and letter duplication and carry suffixes.



      To elaborate, your input will be one or more Zs, then one or more Is, As, or Os (all the same letter), then one or more Ps, (all letters up to this point may be in mixed case) followed by some arbitrary suffix (which may be empty). You should leave the runs of Zs and Ps, as well as the suffix exactly as received, but then change the Is to As, As to Os, or Os to Is, preserving case at each step.



      Example Test Cases



      zip         ==> zap
      zAp ==> zOp
      ZOP ==> ZIP
      ZiiP ==> ZaaP
      ZZaapp ==> ZZoopp
      zzzzOoOPppP ==> zzzzIiIPppP
      Zipperoni ==> Zapperoni
      ZAPsky ==> ZOPsky
      ZoPtOn ==> ZiPtOn
      zipzip ==> zapzip
      zapzopzip ==> zopzopzip
      zoopzaap ==> ziipzaap


      Rules and Notes




      • You may use any convenient character encoding for input and output, provided that it supports all printable ASCII characters, provided that it was created prior to this challenge.

      • You may assume the input word is some variant of Zip, Zap, or Zop. All other inputs result in undefined behavior.


        • Valid inputs will full-match the regex Z+(I+|A+|O+)P+.* (in mixed case)



      • You may assume that the input word consists entirely of ASCII letters.


      Happy Golfing!










      share|improve this question









      $endgroup$




      There's a little improv warm up game where you arrange yourselves in a circle and send zips, zaps, and zops around by pointing to a person and saying the next word in the sequence, then they do the same until all of you are warmed up or whatever.



      Your task is to create a program that gives the next word in sequence given an input word. (Zip --> Zap --> Zop --> Zip) Since there's a lot of different ways to say these three words and flairs that can be added to them, your program should imitate case and letter duplication and carry suffixes.



      To elaborate, your input will be one or more Zs, then one or more Is, As, or Os (all the same letter), then one or more Ps, (all letters up to this point may be in mixed case) followed by some arbitrary suffix (which may be empty). You should leave the runs of Zs and Ps, as well as the suffix exactly as received, but then change the Is to As, As to Os, or Os to Is, preserving case at each step.



      Example Test Cases



      zip         ==> zap
      zAp ==> zOp
      ZOP ==> ZIP
      ZiiP ==> ZaaP
      ZZaapp ==> ZZoopp
      zzzzOoOPppP ==> zzzzIiIPppP
      Zipperoni ==> Zapperoni
      ZAPsky ==> ZOPsky
      ZoPtOn ==> ZiPtOn
      zipzip ==> zapzip
      zapzopzip ==> zopzopzip
      zoopzaap ==> ziipzaap


      Rules and Notes




      • You may use any convenient character encoding for input and output, provided that it supports all printable ASCII characters, provided that it was created prior to this challenge.

      • You may assume the input word is some variant of Zip, Zap, or Zop. All other inputs result in undefined behavior.


        • Valid inputs will full-match the regex Z+(I+|A+|O+)P+.* (in mixed case)



      • You may assume that the input word consists entirely of ASCII letters.


      Happy Golfing!







      code-golf string






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      BeefsterBeefster

      1,772731




      1,772731






















          4 Answers
          4






          active

          oldest

          votes


















          1












          $begingroup$


          Stax, 19 bytes



          Ç╛√êΣ%,╖FP╚`=Lh←⌡·ƒ


          Run and debug it






          share|improve this answer









          $endgroup$





















            1












            $begingroup$


            Perl 6, 41 bytes





            {S:i{z+<(.+?)>p}=$/.&{TR/iaoIAO/aoiAOI/}}


            Try it online!



            Simple case-insensitive substitution to shift the vowel section.






            share|improve this answer









            $endgroup$





















              0












              $begingroup$


              Japt, 22 20 bytes



              -2 bytes thanks to Oliver



              r"%v+"_d`i¬iao¯`pu}"


              Try it online!






              share|improve this answer











              $endgroup$













              • $begingroup$
                @Oliver Oh :/ true
                $endgroup$
                – ASCII-only
                3 mins ago



















              0












              $begingroup$


              JavaScript (Node.js),  69  64 bytes





              s=>Buffer(s).map(c=>s|!(c&3)?s=c:c&1?c-[6,-14,,,8][c%16%5]:c)+''


              Try it online!






              share|improve this answer











              $endgroup$













                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',
                autoActivateHeartbeat: false,
                convertImagesToLinks: false,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f180463%2fplay-zip-zap-zop%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                1












                $begingroup$


                Stax, 19 bytes



                Ç╛√êΣ%,╖FP╚`=Lh←⌡·ƒ


                Run and debug it






                share|improve this answer









                $endgroup$


















                  1












                  $begingroup$


                  Stax, 19 bytes



                  Ç╛√êΣ%,╖FP╚`=Lh←⌡·ƒ


                  Run and debug it






                  share|improve this answer









                  $endgroup$
















                    1












                    1








                    1





                    $begingroup$


                    Stax, 19 bytes



                    Ç╛√êΣ%,╖FP╚`=Lh←⌡·ƒ


                    Run and debug it






                    share|improve this answer









                    $endgroup$




                    Stax, 19 bytes



                    Ç╛√êΣ%,╖FP╚`=Lh←⌡·ƒ


                    Run and debug it







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 1 hour ago









                    recursiverecursive

                    5,3191322




                    5,3191322























                        1












                        $begingroup$


                        Perl 6, 41 bytes





                        {S:i{z+<(.+?)>p}=$/.&{TR/iaoIAO/aoiAOI/}}


                        Try it online!



                        Simple case-insensitive substitution to shift the vowel section.






                        share|improve this answer









                        $endgroup$


















                          1












                          $begingroup$


                          Perl 6, 41 bytes





                          {S:i{z+<(.+?)>p}=$/.&{TR/iaoIAO/aoiAOI/}}


                          Try it online!



                          Simple case-insensitive substitution to shift the vowel section.






                          share|improve this answer









                          $endgroup$
















                            1












                            1








                            1





                            $begingroup$


                            Perl 6, 41 bytes





                            {S:i{z+<(.+?)>p}=$/.&{TR/iaoIAO/aoiAOI/}}


                            Try it online!



                            Simple case-insensitive substitution to shift the vowel section.






                            share|improve this answer









                            $endgroup$




                            Perl 6, 41 bytes





                            {S:i{z+<(.+?)>p}=$/.&{TR/iaoIAO/aoiAOI/}}


                            Try it online!



                            Simple case-insensitive substitution to shift the vowel section.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 55 mins ago









                            Jo KingJo King

                            23.7k257123




                            23.7k257123























                                0












                                $begingroup$


                                Japt, 22 20 bytes



                                -2 bytes thanks to Oliver



                                r"%v+"_d`i¬iao¯`pu}"


                                Try it online!






                                share|improve this answer











                                $endgroup$













                                • $begingroup$
                                  @Oliver Oh :/ true
                                  $endgroup$
                                  – ASCII-only
                                  3 mins ago
















                                0












                                $begingroup$


                                Japt, 22 20 bytes



                                -2 bytes thanks to Oliver



                                r"%v+"_d`i¬iao¯`pu}"


                                Try it online!






                                share|improve this answer











                                $endgroup$













                                • $begingroup$
                                  @Oliver Oh :/ true
                                  $endgroup$
                                  – ASCII-only
                                  3 mins ago














                                0












                                0








                                0





                                $begingroup$


                                Japt, 22 20 bytes



                                -2 bytes thanks to Oliver



                                r"%v+"_d`i¬iao¯`pu}"


                                Try it online!






                                share|improve this answer











                                $endgroup$




                                Japt, 22 20 bytes



                                -2 bytes thanks to Oliver



                                r"%v+"_d`i¬iao¯`pu}"


                                Try it online!







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited 1 min ago

























                                answered 48 mins ago









                                ASCII-onlyASCII-only

                                3,4421236




                                3,4421236












                                • $begingroup$
                                  @Oliver Oh :/ true
                                  $endgroup$
                                  – ASCII-only
                                  3 mins ago


















                                • $begingroup$
                                  @Oliver Oh :/ true
                                  $endgroup$
                                  – ASCII-only
                                  3 mins ago
















                                $begingroup$
                                @Oliver Oh :/ true
                                $endgroup$
                                – ASCII-only
                                3 mins ago




                                $begingroup$
                                @Oliver Oh :/ true
                                $endgroup$
                                – ASCII-only
                                3 mins ago











                                0












                                $begingroup$


                                JavaScript (Node.js),  69  64 bytes





                                s=>Buffer(s).map(c=>s|!(c&3)?s=c:c&1?c-[6,-14,,,8][c%16%5]:c)+''


                                Try it online!






                                share|improve this answer











                                $endgroup$


















                                  0












                                  $begingroup$


                                  JavaScript (Node.js),  69  64 bytes





                                  s=>Buffer(s).map(c=>s|!(c&3)?s=c:c&1?c-[6,-14,,,8][c%16%5]:c)+''


                                  Try it online!






                                  share|improve this answer











                                  $endgroup$
















                                    0












                                    0








                                    0





                                    $begingroup$


                                    JavaScript (Node.js),  69  64 bytes





                                    s=>Buffer(s).map(c=>s|!(c&3)?s=c:c&1?c-[6,-14,,,8][c%16%5]:c)+''


                                    Try it online!






                                    share|improve this answer











                                    $endgroup$




                                    JavaScript (Node.js),  69  64 bytes





                                    s=>Buffer(s).map(c=>s|!(c&3)?s=c:c&1?c-[6,-14,,,8][c%16%5]:c)+''


                                    Try it online!







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited 40 secs ago

























                                    answered 29 mins ago









                                    ArnauldArnauld

                                    76.9k693322




                                    76.9k693322






























                                        draft saved

                                        draft discarded




















































                                        If this is an answer to a challenge…




                                        • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                        • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                          Explanations of your answer make it more interesting to read and are very much encouraged.


                                        • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                        More generally…




                                        • …Please make sure to answer the question and provide sufficient detail.


                                        • …Avoid asking for help, clarification or responding to other answers (use comments instead).





                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f180463%2fplay-zip-zap-zop%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Why is a white electrical wire connected to 2 black wires?

                                        Waikiki

                                        What are all the squawk codes?