ssTTsSTtRrriinInnnnNNNIiinnggFix the Braces, etcChoose The Powerball Numbers!Read n random lines from a potentially huge fileShuffle a mappingLet's abbreviate those numbers! Now reverse?Pick a random number between 0 and n using a constant source of randomnessdeRpiFy tHe sTriNg!Who will win Ghost?That's a lot of monkeysAppend and erase

Unlock My Phone! February 2018

What do you call someone who asks many questions?

Does the Idaho Potato Commission associate potato skins with healthy eating?

Partial fraction expansion confusion

Convert seconds to minutes

How do I exit BASH while loop using modulus operator?

How does a dynamic QR code work?

In Bayesian inference, why are some terms dropped from the posterior predictive?

How to find if SQL server backup is encrypted with TDE without restoring the backup

Why is the sentence "Das ist eine Nase" correct?

What reasons are there for a Capitalist to oppose a 100% inheritance tax?

Why was the shrink from 8″ made only to 5.25″ and not smaller (4″ or less)

Can I hook these wires up to find the connection to a dead outlet?

Why was Sir Cadogan fired?

Finding the reason behind the value of the integral.

Are British MPs missing the point, with these 'Indicative Votes'?

Machine learning testing data

How to enclose theorems and definition in rectangles?

Why are UK visa biometrics appointments suspended at USCIS Application Support Centers?

What are the G forces leaving Earth orbit?

How dangerous is XSS

What is the most common color to indicate the input-field is disabled?

Different meanings of こわい

Car headlights in a world without electricity



ssTTsSTtRrriinInnnnNNNIiinngg


Fix the Braces, etcChoose The Powerball Numbers!Read n random lines from a potentially huge fileShuffle a mappingLet's abbreviate those numbers! Now reverse?Pick a random number between 0 and n using a constant source of randomnessdeRpiFy tHe sTriNg!Who will win Ghost?That's a lot of monkeysAppend and erase













5












$begingroup$


Challenge



For each character of the string except for the last one, do the following:



  • Output the current character.



  • Followed by randomly outputting from the following list a random number of times between 1 and 5 (inclusive):



    • The current character

    • The next character of the string

    • The switchcase version of the character that you are currently on

    • The switchcase version of the next character of the string.


Test Cases



String --> SSSTSStrTrIiinIIngn



, . , . , . Hello world! --> ,,, .. , ,, .... , , .. .. . HHH HHEeelLlLllooO wwOworOOrrrRllDd!!D



Programming Puzzles and Code Golf --> PrPPrRrOooooogggRgGraAraaaMMMmmmimMIiininGGgG PPPPuZzZZzZzzZzllLLEEeEsEsssS a aANnNddD C COCoooOOdeDe E GGGoOllFFf



Notes



  • You only need to apply the upper/lowercase form of a character if the character is part of the upper/lowercase alphabet (A-Z/a-z).

  • Your random function does not need to be uniform but it still needs to have a chance of returning any element in the list given.

  • You are allowed to use any standard I/O format.

  • You may assume that the length of the input is greater than or equal to two.

  • You may assume that the input only consists of ASCII characters.









share|improve this question











$endgroup$











  • $begingroup$
    In addition to '... does not need to be uniform', I think you probably want to specify that given some input, all finite legal outputs should in principle be possible to generate (otherwise, my non-uniform random integer in [1,2,3,4,5] is always going to be 2, and I'll just output the original string).
    $endgroup$
    – Chas Brown
    1 hour ago










  • $begingroup$
    @ChasBrown Yeah, I'll edit the question
    $endgroup$
    – MilkyWay90
    1 hour ago















5












$begingroup$


Challenge



For each character of the string except for the last one, do the following:



  • Output the current character.



  • Followed by randomly outputting from the following list a random number of times between 1 and 5 (inclusive):



    • The current character

    • The next character of the string

    • The switchcase version of the character that you are currently on

    • The switchcase version of the next character of the string.


Test Cases



String --> SSSTSStrTrIiinIIngn



, . , . , . Hello world! --> ,,, .. , ,, .... , , .. .. . HHH HHEeelLlLllooO wwOworOOrrrRllDd!!D



Programming Puzzles and Code Golf --> PrPPrRrOooooogggRgGraAraaaMMMmmmimMIiininGGgG PPPPuZzZZzZzzZzllLLEEeEsEsssS a aANnNddD C COCoooOOdeDe E GGGoOllFFf



Notes



  • You only need to apply the upper/lowercase form of a character if the character is part of the upper/lowercase alphabet (A-Z/a-z).

  • Your random function does not need to be uniform but it still needs to have a chance of returning any element in the list given.

  • You are allowed to use any standard I/O format.

  • You may assume that the length of the input is greater than or equal to two.

  • You may assume that the input only consists of ASCII characters.









share|improve this question











$endgroup$











  • $begingroup$
    In addition to '... does not need to be uniform', I think you probably want to specify that given some input, all finite legal outputs should in principle be possible to generate (otherwise, my non-uniform random integer in [1,2,3,4,5] is always going to be 2, and I'll just output the original string).
    $endgroup$
    – Chas Brown
    1 hour ago










  • $begingroup$
    @ChasBrown Yeah, I'll edit the question
    $endgroup$
    – MilkyWay90
    1 hour ago













5












5








5





$begingroup$


Challenge



For each character of the string except for the last one, do the following:



  • Output the current character.



  • Followed by randomly outputting from the following list a random number of times between 1 and 5 (inclusive):



    • The current character

    • The next character of the string

    • The switchcase version of the character that you are currently on

    • The switchcase version of the next character of the string.


Test Cases



String --> SSSTSStrTrIiinIIngn



, . , . , . Hello world! --> ,,, .. , ,, .... , , .. .. . HHH HHEeelLlLllooO wwOworOOrrrRllDd!!D



Programming Puzzles and Code Golf --> PrPPrRrOooooogggRgGraAraaaMMMmmmimMIiininGGgG PPPPuZzZZzZzzZzllLLEEeEsEsssS a aANnNddD C COCoooOOdeDe E GGGoOllFFf



Notes



  • You only need to apply the upper/lowercase form of a character if the character is part of the upper/lowercase alphabet (A-Z/a-z).

  • Your random function does not need to be uniform but it still needs to have a chance of returning any element in the list given.

  • You are allowed to use any standard I/O format.

  • You may assume that the length of the input is greater than or equal to two.

  • You may assume that the input only consists of ASCII characters.









share|improve this question











$endgroup$




Challenge



For each character of the string except for the last one, do the following:



  • Output the current character.



  • Followed by randomly outputting from the following list a random number of times between 1 and 5 (inclusive):



    • The current character

    • The next character of the string

    • The switchcase version of the character that you are currently on

    • The switchcase version of the next character of the string.


Test Cases



String --> SSSTSStrTrIiinIIngn



, . , . , . Hello world! --> ,,, .. , ,, .... , , .. .. . HHH HHEeelLlLllooO wwOworOOrrrRllDd!!D



Programming Puzzles and Code Golf --> PrPPrRrOooooogggRgGraAraaaMMMmmmimMIiininGGgG PPPPuZzZZzZzzZzllLLEEeEsEsssS a aANnNddD C COCoooOOdeDe E GGGoOllFFf



Notes



  • You only need to apply the upper/lowercase form of a character if the character is part of the upper/lowercase alphabet (A-Z/a-z).

  • Your random function does not need to be uniform but it still needs to have a chance of returning any element in the list given.

  • You are allowed to use any standard I/O format.

  • You may assume that the length of the input is greater than or equal to two.

  • You may assume that the input only consists of ASCII characters.






code-golf random






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago







MilkyWay90

















asked 3 hours ago









MilkyWay90MilkyWay90

619213




619213











  • $begingroup$
    In addition to '... does not need to be uniform', I think you probably want to specify that given some input, all finite legal outputs should in principle be possible to generate (otherwise, my non-uniform random integer in [1,2,3,4,5] is always going to be 2, and I'll just output the original string).
    $endgroup$
    – Chas Brown
    1 hour ago










  • $begingroup$
    @ChasBrown Yeah, I'll edit the question
    $endgroup$
    – MilkyWay90
    1 hour ago
















  • $begingroup$
    In addition to '... does not need to be uniform', I think you probably want to specify that given some input, all finite legal outputs should in principle be possible to generate (otherwise, my non-uniform random integer in [1,2,3,4,5] is always going to be 2, and I'll just output the original string).
    $endgroup$
    – Chas Brown
    1 hour ago










  • $begingroup$
    @ChasBrown Yeah, I'll edit the question
    $endgroup$
    – MilkyWay90
    1 hour ago















$begingroup$
In addition to '... does not need to be uniform', I think you probably want to specify that given some input, all finite legal outputs should in principle be possible to generate (otherwise, my non-uniform random integer in [1,2,3,4,5] is always going to be 2, and I'll just output the original string).
$endgroup$
– Chas Brown
1 hour ago




$begingroup$
In addition to '... does not need to be uniform', I think you probably want to specify that given some input, all finite legal outputs should in principle be possible to generate (otherwise, my non-uniform random integer in [1,2,3,4,5] is always going to be 2, and I'll just output the original string).
$endgroup$
– Chas Brown
1 hour ago












$begingroup$
@ChasBrown Yeah, I'll edit the question
$endgroup$
– MilkyWay90
1 hour ago




$begingroup$
@ChasBrown Yeah, I'll edit the question
$endgroup$
– MilkyWay90
1 hour ago










3 Answers
3






active

oldest

votes


















2












$begingroup$


Gaia, 21 bytes



ṅ@ṇ+†⟨(₌¤:~+ṛ5ṛ&⟩¦$


Try it online!



ṅ			| delete the first character from the input
@ṇ | push the input again and delete the last character
+† | concatenate together, so for example 'abc' 'bcd' becomes ['ab' 'bc' 'cd']
⟨ ⟩¦ | for each of the elements, do:
(₌ | take the first character and push again
¤ | swap
: | dup
~ | swap case
+ | combine strings
ṛ | select a character at random
5ṛ | select a random integer from [1..5]
& | run-length decode
$ | convert to string





share|improve this answer









$endgroup$




















    0












    $begingroup$


    APL (dzaima/APL), 19 bytes





    Anonymous tacit prefix function.



    ∊2(⊣,?5⍴4⊇,,-⍤,)/


    Try it online!



    2()/ apply the following infix tacit function between each character pair:



    - the switchcase

     of

    , the concatenation of the pair



    ,, prepend the concatenation of the pair to that



     pick the following elements from that:



      5⍴4 five fours



      ? random indices for those



    ϵnlist (flatten)






    share|improve this answer









    $endgroup$




















      0












      $begingroup$


      Charcoal, 27 bytes



      FLθ«F∧ι⊕‽⁵‽⭆✂θ⊖ι⊕ι¹⁺↥λ↧λ§θι


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



      FLθ«


      Loop over all of the indices of the input string.



      F∧ι⊕‽⁵


      Except for the first index, loop over a random number from 1 to 5 inclusive...



      ‽⭆✂θ⊖ι⊕ι¹⁺↥λ↧λ


      ... extract the previous and next characters from the string, take the upper and lower case versions, and pick a random character of the four.



      §θι


      Print the character at the current index.






      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%2f182559%2fssttssttrrriininnnnnnniiinngg%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        2












        $begingroup$


        Gaia, 21 bytes



        ṅ@ṇ+†⟨(₌¤:~+ṛ5ṛ&⟩¦$


        Try it online!



        ṅ			| delete the first character from the input
        @ṇ | push the input again and delete the last character
        +† | concatenate together, so for example 'abc' 'bcd' becomes ['ab' 'bc' 'cd']
        ⟨ ⟩¦ | for each of the elements, do:
        (₌ | take the first character and push again
        ¤ | swap
        : | dup
        ~ | swap case
        + | combine strings
        ṛ | select a character at random
        5ṛ | select a random integer from [1..5]
        & | run-length decode
        $ | convert to string





        share|improve this answer









        $endgroup$

















          2












          $begingroup$


          Gaia, 21 bytes



          ṅ@ṇ+†⟨(₌¤:~+ṛ5ṛ&⟩¦$


          Try it online!



          ṅ			| delete the first character from the input
          @ṇ | push the input again and delete the last character
          +† | concatenate together, so for example 'abc' 'bcd' becomes ['ab' 'bc' 'cd']
          ⟨ ⟩¦ | for each of the elements, do:
          (₌ | take the first character and push again
          ¤ | swap
          : | dup
          ~ | swap case
          + | combine strings
          ṛ | select a character at random
          5ṛ | select a random integer from [1..5]
          & | run-length decode
          $ | convert to string





          share|improve this answer









          $endgroup$















            2












            2








            2





            $begingroup$


            Gaia, 21 bytes



            ṅ@ṇ+†⟨(₌¤:~+ṛ5ṛ&⟩¦$


            Try it online!



            ṅ			| delete the first character from the input
            @ṇ | push the input again and delete the last character
            +† | concatenate together, so for example 'abc' 'bcd' becomes ['ab' 'bc' 'cd']
            ⟨ ⟩¦ | for each of the elements, do:
            (₌ | take the first character and push again
            ¤ | swap
            : | dup
            ~ | swap case
            + | combine strings
            ṛ | select a character at random
            5ṛ | select a random integer from [1..5]
            & | run-length decode
            $ | convert to string





            share|improve this answer









            $endgroup$




            Gaia, 21 bytes



            ṅ@ṇ+†⟨(₌¤:~+ṛ5ṛ&⟩¦$


            Try it online!



            ṅ			| delete the first character from the input
            @ṇ | push the input again and delete the last character
            +† | concatenate together, so for example 'abc' 'bcd' becomes ['ab' 'bc' 'cd']
            ⟨ ⟩¦ | for each of the elements, do:
            (₌ | take the first character and push again
            ¤ | swap
            : | dup
            ~ | swap case
            + | combine strings
            ṛ | select a character at random
            5ṛ | select a random integer from [1..5]
            & | run-length decode
            $ | convert to string






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 1 hour ago









            GiuseppeGiuseppe

            17.3k31152




            17.3k31152





















                0












                $begingroup$


                APL (dzaima/APL), 19 bytes





                Anonymous tacit prefix function.



                ∊2(⊣,?5⍴4⊇,,-⍤,)/


                Try it online!



                2()/ apply the following infix tacit function between each character pair:



                - the switchcase

                 of

                , the concatenation of the pair



                ,, prepend the concatenation of the pair to that



                 pick the following elements from that:



                  5⍴4 five fours



                  ? random indices for those



                ϵnlist (flatten)






                share|improve this answer









                $endgroup$

















                  0












                  $begingroup$


                  APL (dzaima/APL), 19 bytes





                  Anonymous tacit prefix function.



                  ∊2(⊣,?5⍴4⊇,,-⍤,)/


                  Try it online!



                  2()/ apply the following infix tacit function between each character pair:



                  - the switchcase

                   of

                  , the concatenation of the pair



                  ,, prepend the concatenation of the pair to that



                   pick the following elements from that:



                    5⍴4 five fours



                    ? random indices for those



                  ϵnlist (flatten)






                  share|improve this answer









                  $endgroup$















                    0












                    0








                    0





                    $begingroup$


                    APL (dzaima/APL), 19 bytes





                    Anonymous tacit prefix function.



                    ∊2(⊣,?5⍴4⊇,,-⍤,)/


                    Try it online!



                    2()/ apply the following infix tacit function between each character pair:



                    - the switchcase

                     of

                    , the concatenation of the pair



                    ,, prepend the concatenation of the pair to that



                     pick the following elements from that:



                      5⍴4 five fours



                      ? random indices for those



                    ϵnlist (flatten)






                    share|improve this answer









                    $endgroup$




                    APL (dzaima/APL), 19 bytes





                    Anonymous tacit prefix function.



                    ∊2(⊣,?5⍴4⊇,,-⍤,)/


                    Try it online!



                    2()/ apply the following infix tacit function between each character pair:



                    - the switchcase

                     of

                    , the concatenation of the pair



                    ,, prepend the concatenation of the pair to that



                     pick the following elements from that:



                      5⍴4 five fours



                      ? random indices for those



                    ϵnlist (flatten)







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 3 hours ago









                    AdámAdám

                    28.8k276207




                    28.8k276207





















                        0












                        $begingroup$


                        Charcoal, 27 bytes



                        FLθ«F∧ι⊕‽⁵‽⭆✂θ⊖ι⊕ι¹⁺↥λ↧λ§θι


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



                        FLθ«


                        Loop over all of the indices of the input string.



                        F∧ι⊕‽⁵


                        Except for the first index, loop over a random number from 1 to 5 inclusive...



                        ‽⭆✂θ⊖ι⊕ι¹⁺↥λ↧λ


                        ... extract the previous and next characters from the string, take the upper and lower case versions, and pick a random character of the four.



                        §θι


                        Print the character at the current index.






                        share|improve this answer









                        $endgroup$

















                          0












                          $begingroup$


                          Charcoal, 27 bytes



                          FLθ«F∧ι⊕‽⁵‽⭆✂θ⊖ι⊕ι¹⁺↥λ↧λ§θι


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



                          FLθ«


                          Loop over all of the indices of the input string.



                          F∧ι⊕‽⁵


                          Except for the first index, loop over a random number from 1 to 5 inclusive...



                          ‽⭆✂θ⊖ι⊕ι¹⁺↥λ↧λ


                          ... extract the previous and next characters from the string, take the upper and lower case versions, and pick a random character of the four.



                          §θι


                          Print the character at the current index.






                          share|improve this answer









                          $endgroup$















                            0












                            0








                            0





                            $begingroup$


                            Charcoal, 27 bytes



                            FLθ«F∧ι⊕‽⁵‽⭆✂θ⊖ι⊕ι¹⁺↥λ↧λ§θι


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



                            FLθ«


                            Loop over all of the indices of the input string.



                            F∧ι⊕‽⁵


                            Except for the first index, loop over a random number from 1 to 5 inclusive...



                            ‽⭆✂θ⊖ι⊕ι¹⁺↥λ↧λ


                            ... extract the previous and next characters from the string, take the upper and lower case versions, and pick a random character of the four.



                            §θι


                            Print the character at the current index.






                            share|improve this answer









                            $endgroup$




                            Charcoal, 27 bytes



                            FLθ«F∧ι⊕‽⁵‽⭆✂θ⊖ι⊕ι¹⁺↥λ↧λ§θι


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



                            FLθ«


                            Loop over all of the indices of the input string.



                            F∧ι⊕‽⁵


                            Except for the first index, loop over a random number from 1 to 5 inclusive...



                            ‽⭆✂θ⊖ι⊕ι¹⁺↥λ↧λ


                            ... extract the previous and next characters from the string, take the upper and lower case versions, and pick a random character of the four.



                            §θι


                            Print the character at the current index.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 3 hours ago









                            NeilNeil

                            82.3k745178




                            82.3k745178



























                                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%2f182559%2fssttssttrrriininnnnnnniiinngg%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

                                名間水力發電廠 目录 沿革 設施 鄰近設施 註釋 外部連結 导航菜单23°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.7113923°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.71139計畫概要原始内容臺灣第一座BOT 模式開發的水力發電廠-名間水力電廠名間水力發電廠 水利署首件BOT案原始内容《小檔案》名間電廠 首座BOT水力發電廠原始内容名間電廠BOT - 經濟部水利署中區水資源局

                                Prove that NP is closed under karp reduction?Space(n) not closed under Karp reductions - what about NTime(n)?Class P is closed under rotation?Prove or disprove that $NL$ is closed under polynomial many-one reductions$mathbfNC_2$ is closed under log-space reductionOn Karp reductionwhen can I know if a class (complexity) is closed under reduction (cook/karp)Check if class $PSPACE$ is closed under polyonomially space reductionIs NPSPACE also closed under polynomial-time reduction and under log-space reduction?Prove PSPACE is closed under complement?Prove PSPACE is closed under union?

                                Is my guitar’s action too high? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Strings too stiff on a recently purchased acoustic guitar | Cort AD880CEIs the action of my guitar really high?Μy little finger is too weak to play guitarWith guitar, how long should I give my fingers to strengthen / callous?When playing a fret the guitar sounds mutedPlaying (Barre) chords up the guitar neckI think my guitar strings are wound too tight and I can't play barre chordsF barre chord on an SG guitarHow to find to the right strings of a barre chord by feel?High action on higher fret on my steel acoustic guitar