ssTTsSTtRrriinInnnnNNNIiinnggTips for golfing in <all languages>Tips for golfing in RNaïve Markov Chain Word GenerationPasswordify the stringCase PermutationUn-de-duplicating stringsFilesystem-sort my directory pleasePick a random number between 0 and n using a constant source of randomnessdeRpiFy tHe sTriNg!Find my polyphthongs!XKCD Calendar FactsCase-fold German

The use of multiple foreign keys on same column in SQL Server

Why was the small council so happy for Tyrion to become the Master of Coin?

Today is the Center

Test if tikzmark exists on same page

Why doesn't H₄O²⁺ exist?

Can I ask the recruiters in my resume to put the reason why I am rejected?

How do I create uniquely male characters?

What's the point of deactivating Num Lock on login screens?

How to say job offer in Mandarin/Cantonese?

What would happen to a modern skyscraper if it rains micro blackholes?

Fully-Firstable Anagram Sets

Can I make popcorn with any corn?

What does it mean to describe someone as a butt steak?

If I cast Expeditious Retreat, can I Dash as a bonus action on the same turn?

Is it legal for company to use my work email to pretend I still work there?

can i play a electric guitar through a bass amp?

Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)

Why do I get two different answers for this counting problem?

Mathematical cryptic clues

How does one intimidate enemies without having the capacity for violence?

In Japanese, what’s the difference between “Tonari ni” (となりに) and “Tsugi” (つぎ)? When would you use one over the other?

Why do falling prices hurt debtors?

What does "Puller Prush Person" mean?

Is it unprofessional to ask if a job posting on GlassDoor is real?



ssTTsSTtRrriinInnnnNNNIiinngg


Tips for golfing in <all languages>Tips for golfing in RNaïve Markov Chain Word GenerationPasswordify the stringCase PermutationUn-de-duplicating stringsFilesystem-sort my directory pleasePick a random number between 0 and n using a constant source of randomnessdeRpiFy tHe sTriNg!Find my polyphthongs!XKCD Calendar FactsCase-fold German













17












$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 - 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 switchcase version of a character if the character is part of the alphabet (A-Z and 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.

  • The title is not a test case (it is unintentional if it is a valid test case).

  • Switchcase means to turn the char to lowercase if it is uppercase and to turn it to uppercase if it is lowercase.









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
    Apr 3 at 1:21










  • $begingroup$
    @ChasBrown Yeah, I'll edit the question
    $endgroup$
    – MilkyWay90
    Apr 3 at 1:39






  • 2




    $begingroup$
    I find the specification confusing. Can you be more explicit? For example, work out how String produces SSSTSStrTrIiinIIngn
    $endgroup$
    – Luis Mendo
    Apr 3 at 9:02







  • 7




    $begingroup$
    @LuisMendo I'm not OP, but I think: [S]SSTSS [t]rT, [r]I, [i]inII, [n]gn, where the characters between the blocks are the first bullet points ("Output the current character"), and the other characters are 1-5 times randomly one of the four choices for that character. But I agree, some more explicit explanations would be appropriate. Apart from the test case it wasn't particularly clear we have to pick a random choice 1-5 times. Instead of picking a random choice repeated 1-5 times (as the Gaia answer currently does).
    $endgroup$
    – Kevin Cruijssen
    Apr 3 at 11:09







  • 3




    $begingroup$
    @KevinCruijssen Thanks, Your explanation fits the example, and is clear. The OP should confirm and edit that into the text
    $endgroup$
    – Luis Mendo
    Apr 3 at 11:19
















17












$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 - 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 switchcase version of a character if the character is part of the alphabet (A-Z and 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.

  • The title is not a test case (it is unintentional if it is a valid test case).

  • Switchcase means to turn the char to lowercase if it is uppercase and to turn it to uppercase if it is lowercase.









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
    Apr 3 at 1:21










  • $begingroup$
    @ChasBrown Yeah, I'll edit the question
    $endgroup$
    – MilkyWay90
    Apr 3 at 1:39






  • 2




    $begingroup$
    I find the specification confusing. Can you be more explicit? For example, work out how String produces SSSTSStrTrIiinIIngn
    $endgroup$
    – Luis Mendo
    Apr 3 at 9:02







  • 7




    $begingroup$
    @LuisMendo I'm not OP, but I think: [S]SSTSS [t]rT, [r]I, [i]inII, [n]gn, where the characters between the blocks are the first bullet points ("Output the current character"), and the other characters are 1-5 times randomly one of the four choices for that character. But I agree, some more explicit explanations would be appropriate. Apart from the test case it wasn't particularly clear we have to pick a random choice 1-5 times. Instead of picking a random choice repeated 1-5 times (as the Gaia answer currently does).
    $endgroup$
    – Kevin Cruijssen
    Apr 3 at 11:09







  • 3




    $begingroup$
    @KevinCruijssen Thanks, Your explanation fits the example, and is clear. The OP should confirm and edit that into the text
    $endgroup$
    – Luis Mendo
    Apr 3 at 11:19














17












17








17


2



$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 - 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 switchcase version of a character if the character is part of the alphabet (A-Z and 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.

  • The title is not a test case (it is unintentional if it is a valid test case).

  • Switchcase means to turn the char to lowercase if it is uppercase and to turn it to uppercase if it is lowercase.









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 - 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 switchcase version of a character if the character is part of the alphabet (A-Z and 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.

  • The title is not a test case (it is unintentional if it is a valid test case).

  • Switchcase means to turn the char to lowercase if it is uppercase and to turn it to uppercase if it is lowercase.






code-golf string random






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 3 at 23:00







MilkyWay90

















asked Apr 2 at 23:23









MilkyWay90MilkyWay90

685315




685315











  • $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
    Apr 3 at 1:21










  • $begingroup$
    @ChasBrown Yeah, I'll edit the question
    $endgroup$
    – MilkyWay90
    Apr 3 at 1:39






  • 2




    $begingroup$
    I find the specification confusing. Can you be more explicit? For example, work out how String produces SSSTSStrTrIiinIIngn
    $endgroup$
    – Luis Mendo
    Apr 3 at 9:02







  • 7




    $begingroup$
    @LuisMendo I'm not OP, but I think: [S]SSTSS [t]rT, [r]I, [i]inII, [n]gn, where the characters between the blocks are the first bullet points ("Output the current character"), and the other characters are 1-5 times randomly one of the four choices for that character. But I agree, some more explicit explanations would be appropriate. Apart from the test case it wasn't particularly clear we have to pick a random choice 1-5 times. Instead of picking a random choice repeated 1-5 times (as the Gaia answer currently does).
    $endgroup$
    – Kevin Cruijssen
    Apr 3 at 11:09







  • 3




    $begingroup$
    @KevinCruijssen Thanks, Your explanation fits the example, and is clear. The OP should confirm and edit that into the text
    $endgroup$
    – Luis Mendo
    Apr 3 at 11:19

















  • $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
    Apr 3 at 1:21










  • $begingroup$
    @ChasBrown Yeah, I'll edit the question
    $endgroup$
    – MilkyWay90
    Apr 3 at 1:39






  • 2




    $begingroup$
    I find the specification confusing. Can you be more explicit? For example, work out how String produces SSSTSStrTrIiinIIngn
    $endgroup$
    – Luis Mendo
    Apr 3 at 9:02







  • 7




    $begingroup$
    @LuisMendo I'm not OP, but I think: [S]SSTSS [t]rT, [r]I, [i]inII, [n]gn, where the characters between the blocks are the first bullet points ("Output the current character"), and the other characters are 1-5 times randomly one of the four choices for that character. But I agree, some more explicit explanations would be appropriate. Apart from the test case it wasn't particularly clear we have to pick a random choice 1-5 times. Instead of picking a random choice repeated 1-5 times (as the Gaia answer currently does).
    $endgroup$
    – Kevin Cruijssen
    Apr 3 at 11:09







  • 3




    $begingroup$
    @KevinCruijssen Thanks, Your explanation fits the example, and is clear. The OP should confirm and edit that into the text
    $endgroup$
    – Luis Mendo
    Apr 3 at 11:19
















$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
Apr 3 at 1:21




$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
Apr 3 at 1:21












$begingroup$
@ChasBrown Yeah, I'll edit the question
$endgroup$
– MilkyWay90
Apr 3 at 1:39




$begingroup$
@ChasBrown Yeah, I'll edit the question
$endgroup$
– MilkyWay90
Apr 3 at 1:39




2




2




$begingroup$
I find the specification confusing. Can you be more explicit? For example, work out how String produces SSSTSStrTrIiinIIngn
$endgroup$
– Luis Mendo
Apr 3 at 9:02





$begingroup$
I find the specification confusing. Can you be more explicit? For example, work out how String produces SSSTSStrTrIiinIIngn
$endgroup$
– Luis Mendo
Apr 3 at 9:02





7




7




$begingroup$
@LuisMendo I'm not OP, but I think: [S]SSTSS [t]rT, [r]I, [i]inII, [n]gn, where the characters between the blocks are the first bullet points ("Output the current character"), and the other characters are 1-5 times randomly one of the four choices for that character. But I agree, some more explicit explanations would be appropriate. Apart from the test case it wasn't particularly clear we have to pick a random choice 1-5 times. Instead of picking a random choice repeated 1-5 times (as the Gaia answer currently does).
$endgroup$
– Kevin Cruijssen
Apr 3 at 11:09





$begingroup$
@LuisMendo I'm not OP, but I think: [S]SSTSS [t]rT, [r]I, [i]inII, [n]gn, where the characters between the blocks are the first bullet points ("Output the current character"), and the other characters are 1-5 times randomly one of the four choices for that character. But I agree, some more explicit explanations would be appropriate. Apart from the test case it wasn't particularly clear we have to pick a random choice 1-5 times. Instead of picking a random choice repeated 1-5 times (as the Gaia answer currently does).
$endgroup$
– Kevin Cruijssen
Apr 3 at 11:09





3




3




$begingroup$
@KevinCruijssen Thanks, Your explanation fits the example, and is clear. The OP should confirm and edit that into the text
$endgroup$
– Luis Mendo
Apr 3 at 11:19





$begingroup$
@KevinCruijssen Thanks, Your explanation fits the example, and is clear. The OP should confirm and edit that into the text
$endgroup$
– Luis Mendo
Apr 3 at 11:19











20 Answers
20






active

oldest

votes


















6












$begingroup$


Gaia, 25 bytes



ṇ+†ṅ⟨)₌¤:~+4ṛ⟨ṛ₌¤⟩ₓ⟩¦$


Try it online!



Thanks to Kevin Cruijssen for pointing out 2 bugs!



ṇ				| delete the last character from the input
+† | push the input again and concatenate together, so for instance
| 'abc' 'bc' becomes ['ab' 'bc' 'c']
ṅ | delete the last element
⟨ ⟩¦ | for each of the elements, do:
)₌ | take the first character and push again
¤ | swap
: | dup
~ | swap case
+ | concatenate strings
4ṛ | select a random integer from [1..5]
⟨ ⟩ₓ | and repeat that many times
ṛ₌¤ | select a random character from the string
| clean up stack
$ | convert to string


Note that 4ṛ is because is implemented for an integer z as python's random.randint(1,z+1), which returns an integer N such that 1<=N<=z+1.






share|improve this answer











$endgroup$












  • $begingroup$
    Are you sure the run-length encode is correct here? If I understand the challenge correctly: the four options should be chosen 1-5 times randomly, instead of choosing one of the four randomly, repeated 1-5 times. The first example output SSSTSStrTrIiinIIngn ([SSSTSS, trT, rI, iinII, ngn]) seems to reflect this, and currently isn't a possible output in your program (I think).
    $endgroup$
    – Kevin Cruijssen
    Apr 3 at 8:56











  • $begingroup$
    @KevinCruijssen I interpreted "output from the list a random number of times" to mean run-length decode, but you're right, the test cases do seem to indicate the other interpretation; I think it should be pretty easy to fix
    $endgroup$
    – Giuseppe
    Apr 3 at 10:50







  • 1




    $begingroup$
    5ṛ can result in 6 for some reason Try it online? PS: Isn't there an integer to ranged list, or ranged for-loop in Gaia?
    $endgroup$
    – Kevin Cruijssen
    Apr 3 at 11:32







  • 1




    $begingroup$
    @KevinCruijssen dang, Business Cat really needs to fix off-by-one errors...I really thought there was a for type construct, but I'm pretty sure it's which isn't even documented on the wiki page.
    $endgroup$
    – Giuseppe
    Apr 3 at 11:41


















3












$begingroup$


APL (dzaima/APL), 23 bytes





Anonymous tacit prefix function.



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


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 random number in range 1…5



  4⍴⍨ that many fours



  ? random indices for those



ϵnlist (flatten)






share|improve this answer











$endgroup$




















    3












    $begingroup$


    Perl 6, 60 bytes





    S:g.)>(.)=$/~[~] roll ^5 .roll+1,$/.lc,$/.uc,$0.lc,$0.uc


    Try it online!



    The lowercase/uppercase part is kinda annoying.






    share|improve this answer









    $endgroup$












    • $begingroup$
      I don't know Perl, so I'm probably saying something stupid here. But is it somehow possible to concat the $/ and $0 together and use .lc on that string, and then create a copy of that string and use .uc, and concat those two together? Not sure if that's even possible, or shorter than your current $/.lc,$/.uc,$0.lc,$0.uc, but it would mean you'd use $/, $0, .lc, and .uc once each.
      $endgroup$
      – Kevin Cruijssen
      Apr 3 at 13:43







    • 1




      $begingroup$
      Alas, (.lc~.uc for $0~$/).comb is longer. Perl 6 really wants to distinguish strings and lists, so "abc"[0] eq "abc" (it pretends to be a single-item list).
      $endgroup$
      – Ven
      Apr 3 at 16:02











    • $begingroup$
      You can do it by slipping and an anonymous function applied to a list: .uc($/,|$0) for -5 bytes, and just use the list of matches .uc(@$/) for -8 bytes. tio.run/…
      $endgroup$
      – Phil H
      2 days ago










    • $begingroup$
      @PhilH No that doesn't work. Those solutions only capitalise one of the letters each
      $endgroup$
      – Jo King
      2 days ago



















    3












    $begingroup$


    Jelly, 12 bytes



    ;Œsṗ5X¤XṭṖµƝ


    Try it online!






    share|improve this answer









    $endgroup$




















      3












      $begingroup$


      Bash, 121 bytes



      -20 bytes thanks to Nahuel



      -9 bytes thanks to roblogic





      for((i=0;i<$#1;i++))
      s=$1:i:1
      m=$1:i:2
      m=$m,,$m^^
      for((t=0;t++<RANDOM%6;))
      s+=$m:RANDOM%4:1

      printf "$s"



      Try it online!



      Original answer




      Bash, 150 bytes



      Have done very little golf bashing and trying to improve my bash, so any comments welcome.





      for((i=0;i<$#1-1;i++));do
      c=$1:$i:1
      n=$1:$((i+1)):1
      a=($n $c, $c^ $n, $n^)
      shuf -e $a[@] -n "$(shuf -i 1-5 -n 1)"|xargs printf %s
      done


      Try it online!



      Code is straightforward loop through chars setting current c and next n character, then creating an array of the 4 possibilities, repeating one of them so there's exactly 5. Next we shuffle that array, and then choose n elements from it, where n itself is random between 1 and 5.






      share|improve this answer











      $endgroup$












      • $begingroup$
        seems it's missing printf %s "$c"
        $endgroup$
        – Nahuel Fouilleul
        Apr 3 at 8:06






      • 1




        $begingroup$
        do and done can be replaced with undocumented and
        $endgroup$
        – Nahuel Fouilleul
        Apr 3 at 8:08










      • $begingroup$
        with some changes
        $endgroup$
        – Nahuel Fouilleul
        Apr 3 at 8:25











      • $begingroup$
        @NahuelFouilleul tyvm. nice improvements and nice catch -- i'd somehow missed the requirement always to output the current char.
        $endgroup$
        – Jonah
        Apr 3 at 13:07






      • 1




        $begingroup$
        @roblogic that's clever. tyvm.
        $endgroup$
        – Jonah
        Apr 3 at 21:36


















      2












      $begingroup$


      Python 2, 107 bytes





      f=lambda s:s and s[0]+''.join(sample((s[:2]+s[:2].swapcase())*5,randint(1,5)))+f(s[1:])
      from random import*


      Try it online!






      share|improve this answer









      $endgroup$




















        2












        $begingroup$


        05AB1E, 18 17 bytes



        ü)vyн5LΩFyD.š«Ω]J


        Inspired by @Giuseppe's Gaia answer.

        -1 byte thanks to @Shaggy.



        Try it online 10 times or verify all test cases 10 times.



        Explanation:





        ü) # Create all pairs of the (implicit) input
        # i.e. "Hello" → [["H","e"],["e","l"],["l","l"],["l","o"]]
        v # Loop over each these pairs `y`:
        yн # Push the first character of pair `y`
        5LΩ # Get a random integer in the range [1,5]
        F # Inner loop that many times:
        y # Push pair `y`
        D.š« # Duplicate it, swap the cases of the letters, and merge it with `y`
        Ω # Then pop and push a random character from this list of four
        ]J # After both loops: join the entire stack together to a single string
        # (which is output implicitly as result)





        share|improve this answer











        $endgroup$












        • $begingroup$
          I don't know 05AB1E but, instead of INè, could you save anything by pushing the first character of y?
          $endgroup$
          – Shaggy
          Apr 3 at 9:06










        • $begingroup$
          @Shaggy Yes, I indeed can.. Thanks! Maybe I should stop golfing for today, I'm a mess, lol..
          $endgroup$
          – Kevin Cruijssen
          Apr 3 at 9:08











        • $begingroup$
          You're a mess? ¨vNUy5LΩFy¹X>è«D.š«Ω?
          $endgroup$
          – Magic Octopus Urn
          Apr 3 at 12:52






        • 1




          $begingroup$
          @MagicOctopusUrn Although a pretty original approach, I'm afraid it doesn't do the first bullet point of the challenge ("Output the current character."), since the result can start with t, T, or s for input "String" in your program, while it's supposed to always start with the S.
          $endgroup$
          – Kevin Cruijssen
          Apr 3 at 13:03



















        1












        $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$




















          1












          $begingroup$

          perl 5 (-p), 77 bytes



          s/(.)(?=(.))/$x=$1;'$x.=substr"U$1$2L$1$2",4*rand,1;'x(1+5*rand)/gee;s/.$//


          TIO






          share|improve this answer









          $endgroup$












          • $begingroup$
            You can save 4 bytes by using $& instead of $1, and chop + -l instead of s/.$//
            $endgroup$
            – Dada
            2 days ago


















          1












          $begingroup$


          Japt -P, 14 bytes



          äÈ+Zu pv ö5ö Ä


          Try it



          äÈ+Zu pv ö5ö Ä :Implicit input of string
          ä :Take each consectutive pair of characters
          È :Pass them through the following function as Z
          + : Append to the first character of the pair
          Zu : Uppercase Z
          p : Append
          v : Lowercase
          ö : Get X random characters, where X is
          5ö : Random number in the range [0,5)
          Ä : Plus 1
          :Implicitly join and output





          share|improve this answer











          $endgroup$




















            1












            $begingroup$


            Python 3, 167 bytes





            from random import*;c=choice
            def f(s):
            i=0;r=""
            for i in range(len(s)-1):
            r+=s[i]
            for j in range(randrange(5)):r+=c([str.upper,str.lower])(c(s[i:i+2]))
            return r


            Try it online!






            share|improve this answer









            $endgroup$




















              1












              $begingroup$


              Jelly, 14 bytes



              ;;;Œs$Xɗ¥5X¤¡Ɲ


              Try it online!



              Explanation



               Ɲ | For each overlapping pair of letters
              ; | Join the first letter to...
              5X¤¡ | Between 1 and 5 repetitions of...
              Xɗ¥ | A randomly selected character from...
              ;;Œs$ | A list of the two letters and the swapped case versions of both





              share|improve this answer











              $endgroup$




















                1












                $begingroup$

                C(GCC) 175 162 bytes



                -12 bytes from LambdaBeta



                f(s,S,i,r,a)char*s,*S,*i;srand(time(0));for(i=S;*(s+1);++s)a>64&a<91?a^32:a:a)a=rand()&1?*s:*(s+1);*i=0;


                Try it online






                share|improve this answer











                $endgroup$












                • $begingroup$
                  I don't think you need the 0 in the first line.
                  $endgroup$
                  – LambdaBeta
                  Apr 3 at 21:28










                • $begingroup$
                  Also can save a lot of characters by taking the buffer S as a parameter and adding your variables to the argument list: Try it online!
                  $endgroup$
                  – LambdaBeta
                  Apr 3 at 21:31










                • $begingroup$
                  @LambdaBeta turns out you are right about the 0, which made it not worth it to have the #define anymore
                  $endgroup$
                  – rtpax
                  2 days ago


















                0












                $begingroup$


                Scala 2.12.8, 214 bytes



                Golfed version:



                val r=scala.util.Random;println(readLine.toList.sliding(2).flatMapcase a :: b :: Nil=>(a +: (0 to r.nextInt(5)).map_=>((c: Char)=>if(r.nextBoolean)c.toUpper else c.toLower)(if(r.nextBoolean)a else b)).mkString)


                Golfed with newlines and indents:



                val r=scala.util.Random
                println(readLine.toList.sliding(2).flatMap
                case a :: b :: Nil=>
                (a +: (0 to r.nextInt(5)).map_=>
                ((c: Char)=>if(r.nextBoolean)c.toUpper else c.toLower)(if(r.nextBoolean)a else b)
                )
                .mkString)


                Ungolfed:



                import scala.io.StdIn
                import scala.util.Random

                def gobble(input: String): String =
                input.toList.sliding(2).flatMap
                case thisChar :: nextChar :: Nil =>
                val numberOfAdditions = Random.nextInt(5)
                (thisChar +: (0 to numberOfAdditions).map _ =>
                val char = if(Random.nextBoolean) thisChar else nextChar
                val cc = if(Random.nextBoolean) char.toUpper else char.ToLower
                cc
                )
                .mkString


                println(gobble(StdIn.readLine()))





                share|improve this answer









                $endgroup$








                • 1




                  $begingroup$
                  No way to turn a :: b :: Nil into a::b::Nil? Same for a :+, a:+() or a.:+() might work
                  $endgroup$
                  – Ven
                  2 days ago










                • $begingroup$
                  @Ven a::b::Nil causes a compile error. +: is a method defined on the list, so it might save space by getting rid of the outer parens?
                  $endgroup$
                  – Soren
                  2 days ago











                • $begingroup$
                  You only have only one elem here so it’s not autotupling anyway
                  $endgroup$
                  – Ven
                  2 days ago


















                0












                $begingroup$


                Perl 5 -n, 61 bytes





                s/.(?=(.))/print$&,map(maplc,uc$&,$1)[rand 4]0..rand 5/ge


                Try it online!






                share|improve this answer









                $endgroup$




















                  0












                  $begingroup$


                  C# (Visual C# Interactive Compiler), 236 213 209 bytes





                  a=>int i=0,j;var m=new Random();var s="";var c = a.Select(x=>Char.IsLetter(x)?(char)(x^32):x).ToArray();for(;i<a.Length-1;i++)for(j=m.Next(1,5);j-->0;)s+=new[]a[i],c[i],a[i+1],c[i+1][m.Next(0,3)];return s;


                  Try it online!






                  share|improve this answer











                  $endgroup$












                  • $begingroup$
                    Does not work with non-alphanumeric characters. char b=a[0] -> var b=a[0], extra space in declaration of d in for-loop
                    $endgroup$
                    – Embodiment of Ignorance
                    2 days ago


















                  0












                  $begingroup$

                  T-SQL query, 286 bytes



                  DECLARE @ char(999)='String'

                  SELECT @=stuff(@,n+2,0,s)FROM(SELECT
                  top 999*,substring(lower(c)+upper(c),abs(v%4)+1,1)s
                  FROM(SELECT*,number n,substring(@,number+1,2)c,cast(newid()as varbinary)v
                  FROM(values(1),(2),(3),(4),(5))F(h),spt_values)D
                  WHERE'P'=type and n<len(@)-1and h>v%3+2ORDER
                  BY-n)E
                  PRINT LEFT(@,len(@)-1)


                  Try it online unfortunately the online version always show the same result for the same varchar, unlike MS SQL Server Management Studio






                  share|improve this answer











                  $endgroup$




















                    0












                    $begingroup$


                    C# (Visual C# Interactive Compiler), 156 bytes





                    n=>var k=new Random();int i=0;foreach(var j in n.Skip(1).Zip(n,(a,b)=>a+b))for(Write(j[1]),i=0;i++<k.Next(5);)Write(k.Next()%2<1?j.ToUpper():j.ToLower());


                    Try it online!






                    share|improve this answer











                    $endgroup$




















                      0












                      $begingroup$


                      Japt -P, 43 16 bytes



                      äÈ+(Zv +Zu)ö5ö Ä


                      Shortened by a lot now!



                      Try it






                      share|improve this answer











                      $endgroup$












                      • $begingroup$
                        This seems to return the same result every time.
                        $endgroup$
                        – Shaggy
                        Apr 3 at 10:01










                      • $begingroup$
                        @Shaggy will fix. Also, ä's description says it gives three arguments, with the last being x+y. But as you can see here, it just returns 1. Is this a bug?
                        $endgroup$
                        – Embodiment of Ignorance
                        2 days ago


















                      0












                      $begingroup$


                      C (gcc), 110 bytes





                      i,p;g(char*_)for(i=rand()%1024,putchar(*_);p=_[i%2],putchar(i&2&&p>64&~-p%32<26?p^32:p),i/=4;);_[2]&&g(_+1);


                      Try it online!



                      i,p;g(char*_)
                      for(i=rand()%1024, //initialize: get 10 random bits
                      putchar(*_); // and print current char
                      p=_[i%2], //1st bit => current/next char
                      putchar(i&2&& //2nd bit => toggle case
                      p>64&~-p%32<26 // but only if char-to-print is alphabetic
                      ?p^32:p),
                      i/=4;); //discard two bits; run at least once
                      _[2]&&g(_+1); //if not last char, repeat with next char




                      The number of characters printed (per input character) is not uniformly random:



                      1 if i< 4 ( 4/1024 = 1/256)
                      2 if 4<=i< 16 ( 12/1024 = 3/256)
                      3 if 16<=i< 64 ( 48/1024 = 3/ 64)
                      4 if 64<=i< 256 (192/1024 = 3/ 16)
                      5 if 256<=i<1023 (768/1024 = 3/ 4)





                      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

























                        20 Answers
                        20






                        active

                        oldest

                        votes








                        20 Answers
                        20






                        active

                        oldest

                        votes









                        active

                        oldest

                        votes






                        active

                        oldest

                        votes









                        6












                        $begingroup$


                        Gaia, 25 bytes



                        ṇ+†ṅ⟨)₌¤:~+4ṛ⟨ṛ₌¤⟩ₓ⟩¦$


                        Try it online!



                        Thanks to Kevin Cruijssen for pointing out 2 bugs!



                        ṇ				| delete the last character from the input
                        +† | push the input again and concatenate together, so for instance
                        | 'abc' 'bc' becomes ['ab' 'bc' 'c']
                        ṅ | delete the last element
                        ⟨ ⟩¦ | for each of the elements, do:
                        )₌ | take the first character and push again
                        ¤ | swap
                        : | dup
                        ~ | swap case
                        + | concatenate strings
                        4ṛ | select a random integer from [1..5]
                        ⟨ ⟩ₓ | and repeat that many times
                        ṛ₌¤ | select a random character from the string
                        | clean up stack
                        $ | convert to string


                        Note that 4ṛ is because is implemented for an integer z as python's random.randint(1,z+1), which returns an integer N such that 1<=N<=z+1.






                        share|improve this answer











                        $endgroup$












                        • $begingroup$
                          Are you sure the run-length encode is correct here? If I understand the challenge correctly: the four options should be chosen 1-5 times randomly, instead of choosing one of the four randomly, repeated 1-5 times. The first example output SSSTSStrTrIiinIIngn ([SSSTSS, trT, rI, iinII, ngn]) seems to reflect this, and currently isn't a possible output in your program (I think).
                          $endgroup$
                          – Kevin Cruijssen
                          Apr 3 at 8:56











                        • $begingroup$
                          @KevinCruijssen I interpreted "output from the list a random number of times" to mean run-length decode, but you're right, the test cases do seem to indicate the other interpretation; I think it should be pretty easy to fix
                          $endgroup$
                          – Giuseppe
                          Apr 3 at 10:50







                        • 1




                          $begingroup$
                          5ṛ can result in 6 for some reason Try it online? PS: Isn't there an integer to ranged list, or ranged for-loop in Gaia?
                          $endgroup$
                          – Kevin Cruijssen
                          Apr 3 at 11:32







                        • 1




                          $begingroup$
                          @KevinCruijssen dang, Business Cat really needs to fix off-by-one errors...I really thought there was a for type construct, but I'm pretty sure it's which isn't even documented on the wiki page.
                          $endgroup$
                          – Giuseppe
                          Apr 3 at 11:41















                        6












                        $begingroup$


                        Gaia, 25 bytes



                        ṇ+†ṅ⟨)₌¤:~+4ṛ⟨ṛ₌¤⟩ₓ⟩¦$


                        Try it online!



                        Thanks to Kevin Cruijssen for pointing out 2 bugs!



                        ṇ				| delete the last character from the input
                        +† | push the input again and concatenate together, so for instance
                        | 'abc' 'bc' becomes ['ab' 'bc' 'c']
                        ṅ | delete the last element
                        ⟨ ⟩¦ | for each of the elements, do:
                        )₌ | take the first character and push again
                        ¤ | swap
                        : | dup
                        ~ | swap case
                        + | concatenate strings
                        4ṛ | select a random integer from [1..5]
                        ⟨ ⟩ₓ | and repeat that many times
                        ṛ₌¤ | select a random character from the string
                        | clean up stack
                        $ | convert to string


                        Note that 4ṛ is because is implemented for an integer z as python's random.randint(1,z+1), which returns an integer N such that 1<=N<=z+1.






                        share|improve this answer











                        $endgroup$












                        • $begingroup$
                          Are you sure the run-length encode is correct here? If I understand the challenge correctly: the four options should be chosen 1-5 times randomly, instead of choosing one of the four randomly, repeated 1-5 times. The first example output SSSTSStrTrIiinIIngn ([SSSTSS, trT, rI, iinII, ngn]) seems to reflect this, and currently isn't a possible output in your program (I think).
                          $endgroup$
                          – Kevin Cruijssen
                          Apr 3 at 8:56











                        • $begingroup$
                          @KevinCruijssen I interpreted "output from the list a random number of times" to mean run-length decode, but you're right, the test cases do seem to indicate the other interpretation; I think it should be pretty easy to fix
                          $endgroup$
                          – Giuseppe
                          Apr 3 at 10:50







                        • 1




                          $begingroup$
                          5ṛ can result in 6 for some reason Try it online? PS: Isn't there an integer to ranged list, or ranged for-loop in Gaia?
                          $endgroup$
                          – Kevin Cruijssen
                          Apr 3 at 11:32







                        • 1




                          $begingroup$
                          @KevinCruijssen dang, Business Cat really needs to fix off-by-one errors...I really thought there was a for type construct, but I'm pretty sure it's which isn't even documented on the wiki page.
                          $endgroup$
                          – Giuseppe
                          Apr 3 at 11:41













                        6












                        6








                        6





                        $begingroup$


                        Gaia, 25 bytes



                        ṇ+†ṅ⟨)₌¤:~+4ṛ⟨ṛ₌¤⟩ₓ⟩¦$


                        Try it online!



                        Thanks to Kevin Cruijssen for pointing out 2 bugs!



                        ṇ				| delete the last character from the input
                        +† | push the input again and concatenate together, so for instance
                        | 'abc' 'bc' becomes ['ab' 'bc' 'c']
                        ṅ | delete the last element
                        ⟨ ⟩¦ | for each of the elements, do:
                        )₌ | take the first character and push again
                        ¤ | swap
                        : | dup
                        ~ | swap case
                        + | concatenate strings
                        4ṛ | select a random integer from [1..5]
                        ⟨ ⟩ₓ | and repeat that many times
                        ṛ₌¤ | select a random character from the string
                        | clean up stack
                        $ | convert to string


                        Note that 4ṛ is because is implemented for an integer z as python's random.randint(1,z+1), which returns an integer N such that 1<=N<=z+1.






                        share|improve this answer











                        $endgroup$




                        Gaia, 25 bytes



                        ṇ+†ṅ⟨)₌¤:~+4ṛ⟨ṛ₌¤⟩ₓ⟩¦$


                        Try it online!



                        Thanks to Kevin Cruijssen for pointing out 2 bugs!



                        ṇ				| delete the last character from the input
                        +† | push the input again and concatenate together, so for instance
                        | 'abc' 'bc' becomes ['ab' 'bc' 'c']
                        ṅ | delete the last element
                        ⟨ ⟩¦ | for each of the elements, do:
                        )₌ | take the first character and push again
                        ¤ | swap
                        : | dup
                        ~ | swap case
                        + | concatenate strings
                        4ṛ | select a random integer from [1..5]
                        ⟨ ⟩ₓ | and repeat that many times
                        ṛ₌¤ | select a random character from the string
                        | clean up stack
                        $ | convert to string


                        Note that 4ṛ is because is implemented for an integer z as python's random.randint(1,z+1), which returns an integer N such that 1<=N<=z+1.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Apr 3 at 18:27

























                        answered Apr 3 at 1:34









                        GiuseppeGiuseppe

                        17.6k31153




                        17.6k31153











                        • $begingroup$
                          Are you sure the run-length encode is correct here? If I understand the challenge correctly: the four options should be chosen 1-5 times randomly, instead of choosing one of the four randomly, repeated 1-5 times. The first example output SSSTSStrTrIiinIIngn ([SSSTSS, trT, rI, iinII, ngn]) seems to reflect this, and currently isn't a possible output in your program (I think).
                          $endgroup$
                          – Kevin Cruijssen
                          Apr 3 at 8:56











                        • $begingroup$
                          @KevinCruijssen I interpreted "output from the list a random number of times" to mean run-length decode, but you're right, the test cases do seem to indicate the other interpretation; I think it should be pretty easy to fix
                          $endgroup$
                          – Giuseppe
                          Apr 3 at 10:50







                        • 1




                          $begingroup$
                          5ṛ can result in 6 for some reason Try it online? PS: Isn't there an integer to ranged list, or ranged for-loop in Gaia?
                          $endgroup$
                          – Kevin Cruijssen
                          Apr 3 at 11:32







                        • 1




                          $begingroup$
                          @KevinCruijssen dang, Business Cat really needs to fix off-by-one errors...I really thought there was a for type construct, but I'm pretty sure it's which isn't even documented on the wiki page.
                          $endgroup$
                          – Giuseppe
                          Apr 3 at 11:41
















                        • $begingroup$
                          Are you sure the run-length encode is correct here? If I understand the challenge correctly: the four options should be chosen 1-5 times randomly, instead of choosing one of the four randomly, repeated 1-5 times. The first example output SSSTSStrTrIiinIIngn ([SSSTSS, trT, rI, iinII, ngn]) seems to reflect this, and currently isn't a possible output in your program (I think).
                          $endgroup$
                          – Kevin Cruijssen
                          Apr 3 at 8:56











                        • $begingroup$
                          @KevinCruijssen I interpreted "output from the list a random number of times" to mean run-length decode, but you're right, the test cases do seem to indicate the other interpretation; I think it should be pretty easy to fix
                          $endgroup$
                          – Giuseppe
                          Apr 3 at 10:50







                        • 1




                          $begingroup$
                          5ṛ can result in 6 for some reason Try it online? PS: Isn't there an integer to ranged list, or ranged for-loop in Gaia?
                          $endgroup$
                          – Kevin Cruijssen
                          Apr 3 at 11:32







                        • 1




                          $begingroup$
                          @KevinCruijssen dang, Business Cat really needs to fix off-by-one errors...I really thought there was a for type construct, but I'm pretty sure it's which isn't even documented on the wiki page.
                          $endgroup$
                          – Giuseppe
                          Apr 3 at 11:41















                        $begingroup$
                        Are you sure the run-length encode is correct here? If I understand the challenge correctly: the four options should be chosen 1-5 times randomly, instead of choosing one of the four randomly, repeated 1-5 times. The first example output SSSTSStrTrIiinIIngn ([SSSTSS, trT, rI, iinII, ngn]) seems to reflect this, and currently isn't a possible output in your program (I think).
                        $endgroup$
                        – Kevin Cruijssen
                        Apr 3 at 8:56





                        $begingroup$
                        Are you sure the run-length encode is correct here? If I understand the challenge correctly: the four options should be chosen 1-5 times randomly, instead of choosing one of the four randomly, repeated 1-5 times. The first example output SSSTSStrTrIiinIIngn ([SSSTSS, trT, rI, iinII, ngn]) seems to reflect this, and currently isn't a possible output in your program (I think).
                        $endgroup$
                        – Kevin Cruijssen
                        Apr 3 at 8:56













                        $begingroup$
                        @KevinCruijssen I interpreted "output from the list a random number of times" to mean run-length decode, but you're right, the test cases do seem to indicate the other interpretation; I think it should be pretty easy to fix
                        $endgroup$
                        – Giuseppe
                        Apr 3 at 10:50





                        $begingroup$
                        @KevinCruijssen I interpreted "output from the list a random number of times" to mean run-length decode, but you're right, the test cases do seem to indicate the other interpretation; I think it should be pretty easy to fix
                        $endgroup$
                        – Giuseppe
                        Apr 3 at 10:50





                        1




                        1




                        $begingroup$
                        5ṛ can result in 6 for some reason Try it online? PS: Isn't there an integer to ranged list, or ranged for-loop in Gaia?
                        $endgroup$
                        – Kevin Cruijssen
                        Apr 3 at 11:32





                        $begingroup$
                        5ṛ can result in 6 for some reason Try it online? PS: Isn't there an integer to ranged list, or ranged for-loop in Gaia?
                        $endgroup$
                        – Kevin Cruijssen
                        Apr 3 at 11:32





                        1




                        1




                        $begingroup$
                        @KevinCruijssen dang, Business Cat really needs to fix off-by-one errors...I really thought there was a for type construct, but I'm pretty sure it's which isn't even documented on the wiki page.
                        $endgroup$
                        – Giuseppe
                        Apr 3 at 11:41




                        $begingroup$
                        @KevinCruijssen dang, Business Cat really needs to fix off-by-one errors...I really thought there was a for type construct, but I'm pretty sure it's which isn't even documented on the wiki page.
                        $endgroup$
                        – Giuseppe
                        Apr 3 at 11:41











                        3












                        $begingroup$


                        APL (dzaima/APL), 23 bytes





                        Anonymous tacit prefix function.



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


                        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 random number in range 1…5



                          4⍴⍨ that many fours



                          ? random indices for those



                        ϵnlist (flatten)






                        share|improve this answer











                        $endgroup$

















                          3












                          $begingroup$


                          APL (dzaima/APL), 23 bytes





                          Anonymous tacit prefix function.



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


                          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 random number in range 1…5



                            4⍴⍨ that many fours



                            ? random indices for those



                          ϵnlist (flatten)






                          share|improve this answer











                          $endgroup$















                            3












                            3








                            3





                            $begingroup$


                            APL (dzaima/APL), 23 bytes





                            Anonymous tacit prefix function.



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


                            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 random number in range 1…5



                              4⍴⍨ that many fours



                              ? random indices for those



                            ϵnlist (flatten)






                            share|improve this answer











                            $endgroup$




                            APL (dzaima/APL), 23 bytes





                            Anonymous tacit prefix function.



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


                            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 random number in range 1…5



                              4⍴⍨ that many fours



                              ? random indices for those



                            ϵnlist (flatten)







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Apr 3 at 8:08

























                            answered Apr 2 at 23:24









                            AdámAdám

                            28.9k276207




                            28.9k276207





















                                3












                                $begingroup$


                                Perl 6, 60 bytes





                                S:g.)>(.)=$/~[~] roll ^5 .roll+1,$/.lc,$/.uc,$0.lc,$0.uc


                                Try it online!



                                The lowercase/uppercase part is kinda annoying.






                                share|improve this answer









                                $endgroup$












                                • $begingroup$
                                  I don't know Perl, so I'm probably saying something stupid here. But is it somehow possible to concat the $/ and $0 together and use .lc on that string, and then create a copy of that string and use .uc, and concat those two together? Not sure if that's even possible, or shorter than your current $/.lc,$/.uc,$0.lc,$0.uc, but it would mean you'd use $/, $0, .lc, and .uc once each.
                                  $endgroup$
                                  – Kevin Cruijssen
                                  Apr 3 at 13:43







                                • 1




                                  $begingroup$
                                  Alas, (.lc~.uc for $0~$/).comb is longer. Perl 6 really wants to distinguish strings and lists, so "abc"[0] eq "abc" (it pretends to be a single-item list).
                                  $endgroup$
                                  – Ven
                                  Apr 3 at 16:02











                                • $begingroup$
                                  You can do it by slipping and an anonymous function applied to a list: .uc($/,|$0) for -5 bytes, and just use the list of matches .uc(@$/) for -8 bytes. tio.run/…
                                  $endgroup$
                                  – Phil H
                                  2 days ago










                                • $begingroup$
                                  @PhilH No that doesn't work. Those solutions only capitalise one of the letters each
                                  $endgroup$
                                  – Jo King
                                  2 days ago
















                                3












                                $begingroup$


                                Perl 6, 60 bytes





                                S:g.)>(.)=$/~[~] roll ^5 .roll+1,$/.lc,$/.uc,$0.lc,$0.uc


                                Try it online!



                                The lowercase/uppercase part is kinda annoying.






                                share|improve this answer









                                $endgroup$












                                • $begingroup$
                                  I don't know Perl, so I'm probably saying something stupid here. But is it somehow possible to concat the $/ and $0 together and use .lc on that string, and then create a copy of that string and use .uc, and concat those two together? Not sure if that's even possible, or shorter than your current $/.lc,$/.uc,$0.lc,$0.uc, but it would mean you'd use $/, $0, .lc, and .uc once each.
                                  $endgroup$
                                  – Kevin Cruijssen
                                  Apr 3 at 13:43







                                • 1




                                  $begingroup$
                                  Alas, (.lc~.uc for $0~$/).comb is longer. Perl 6 really wants to distinguish strings and lists, so "abc"[0] eq "abc" (it pretends to be a single-item list).
                                  $endgroup$
                                  – Ven
                                  Apr 3 at 16:02











                                • $begingroup$
                                  You can do it by slipping and an anonymous function applied to a list: .uc($/,|$0) for -5 bytes, and just use the list of matches .uc(@$/) for -8 bytes. tio.run/…
                                  $endgroup$
                                  – Phil H
                                  2 days ago










                                • $begingroup$
                                  @PhilH No that doesn't work. Those solutions only capitalise one of the letters each
                                  $endgroup$
                                  – Jo King
                                  2 days ago














                                3












                                3








                                3





                                $begingroup$


                                Perl 6, 60 bytes





                                S:g.)>(.)=$/~[~] roll ^5 .roll+1,$/.lc,$/.uc,$0.lc,$0.uc


                                Try it online!



                                The lowercase/uppercase part is kinda annoying.






                                share|improve this answer









                                $endgroup$




                                Perl 6, 60 bytes





                                S:g.)>(.)=$/~[~] roll ^5 .roll+1,$/.lc,$/.uc,$0.lc,$0.uc


                                Try it online!



                                The lowercase/uppercase part is kinda annoying.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Apr 3 at 9:25









                                Jo KingJo King

                                26.5k364130




                                26.5k364130











                                • $begingroup$
                                  I don't know Perl, so I'm probably saying something stupid here. But is it somehow possible to concat the $/ and $0 together and use .lc on that string, and then create a copy of that string and use .uc, and concat those two together? Not sure if that's even possible, or shorter than your current $/.lc,$/.uc,$0.lc,$0.uc, but it would mean you'd use $/, $0, .lc, and .uc once each.
                                  $endgroup$
                                  – Kevin Cruijssen
                                  Apr 3 at 13:43







                                • 1




                                  $begingroup$
                                  Alas, (.lc~.uc for $0~$/).comb is longer. Perl 6 really wants to distinguish strings and lists, so "abc"[0] eq "abc" (it pretends to be a single-item list).
                                  $endgroup$
                                  – Ven
                                  Apr 3 at 16:02











                                • $begingroup$
                                  You can do it by slipping and an anonymous function applied to a list: .uc($/,|$0) for -5 bytes, and just use the list of matches .uc(@$/) for -8 bytes. tio.run/…
                                  $endgroup$
                                  – Phil H
                                  2 days ago










                                • $begingroup$
                                  @PhilH No that doesn't work. Those solutions only capitalise one of the letters each
                                  $endgroup$
                                  – Jo King
                                  2 days ago

















                                • $begingroup$
                                  I don't know Perl, so I'm probably saying something stupid here. But is it somehow possible to concat the $/ and $0 together and use .lc on that string, and then create a copy of that string and use .uc, and concat those two together? Not sure if that's even possible, or shorter than your current $/.lc,$/.uc,$0.lc,$0.uc, but it would mean you'd use $/, $0, .lc, and .uc once each.
                                  $endgroup$
                                  – Kevin Cruijssen
                                  Apr 3 at 13:43







                                • 1




                                  $begingroup$
                                  Alas, (.lc~.uc for $0~$/).comb is longer. Perl 6 really wants to distinguish strings and lists, so "abc"[0] eq "abc" (it pretends to be a single-item list).
                                  $endgroup$
                                  – Ven
                                  Apr 3 at 16:02











                                • $begingroup$
                                  You can do it by slipping and an anonymous function applied to a list: .uc($/,|$0) for -5 bytes, and just use the list of matches .uc(@$/) for -8 bytes. tio.run/…
                                  $endgroup$
                                  – Phil H
                                  2 days ago










                                • $begingroup$
                                  @PhilH No that doesn't work. Those solutions only capitalise one of the letters each
                                  $endgroup$
                                  – Jo King
                                  2 days ago
















                                $begingroup$
                                I don't know Perl, so I'm probably saying something stupid here. But is it somehow possible to concat the $/ and $0 together and use .lc on that string, and then create a copy of that string and use .uc, and concat those two together? Not sure if that's even possible, or shorter than your current $/.lc,$/.uc,$0.lc,$0.uc, but it would mean you'd use $/, $0, .lc, and .uc once each.
                                $endgroup$
                                – Kevin Cruijssen
                                Apr 3 at 13:43





                                $begingroup$
                                I don't know Perl, so I'm probably saying something stupid here. But is it somehow possible to concat the $/ and $0 together and use .lc on that string, and then create a copy of that string and use .uc, and concat those two together? Not sure if that's even possible, or shorter than your current $/.lc,$/.uc,$0.lc,$0.uc, but it would mean you'd use $/, $0, .lc, and .uc once each.
                                $endgroup$
                                – Kevin Cruijssen
                                Apr 3 at 13:43





                                1




                                1




                                $begingroup$
                                Alas, (.lc~.uc for $0~$/).comb is longer. Perl 6 really wants to distinguish strings and lists, so "abc"[0] eq "abc" (it pretends to be a single-item list).
                                $endgroup$
                                – Ven
                                Apr 3 at 16:02





                                $begingroup$
                                Alas, (.lc~.uc for $0~$/).comb is longer. Perl 6 really wants to distinguish strings and lists, so "abc"[0] eq "abc" (it pretends to be a single-item list).
                                $endgroup$
                                – Ven
                                Apr 3 at 16:02













                                $begingroup$
                                You can do it by slipping and an anonymous function applied to a list: .uc($/,|$0) for -5 bytes, and just use the list of matches .uc(@$/) for -8 bytes. tio.run/…
                                $endgroup$
                                – Phil H
                                2 days ago




                                $begingroup$
                                You can do it by slipping and an anonymous function applied to a list: .uc($/,|$0) for -5 bytes, and just use the list of matches .uc(@$/) for -8 bytes. tio.run/…
                                $endgroup$
                                – Phil H
                                2 days ago












                                $begingroup$
                                @PhilH No that doesn't work. Those solutions only capitalise one of the letters each
                                $endgroup$
                                – Jo King
                                2 days ago





                                $begingroup$
                                @PhilH No that doesn't work. Those solutions only capitalise one of the letters each
                                $endgroup$
                                – Jo King
                                2 days ago












                                3












                                $begingroup$


                                Jelly, 12 bytes



                                ;Œsṗ5X¤XṭṖµƝ


                                Try it online!






                                share|improve this answer









                                $endgroup$

















                                  3












                                  $begingroup$


                                  Jelly, 12 bytes



                                  ;Œsṗ5X¤XṭṖµƝ


                                  Try it online!






                                  share|improve this answer









                                  $endgroup$















                                    3












                                    3








                                    3





                                    $begingroup$


                                    Jelly, 12 bytes



                                    ;Œsṗ5X¤XṭṖµƝ


                                    Try it online!






                                    share|improve this answer









                                    $endgroup$




                                    Jelly, 12 bytes



                                    ;Œsṗ5X¤XṭṖµƝ


                                    Try it online!







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Apr 3 at 17:06









                                    Erik the OutgolferErik the Outgolfer

                                    32.9k429106




                                    32.9k429106





















                                        3












                                        $begingroup$


                                        Bash, 121 bytes



                                        -20 bytes thanks to Nahuel



                                        -9 bytes thanks to roblogic





                                        for((i=0;i<$#1;i++))
                                        s=$1:i:1
                                        m=$1:i:2
                                        m=$m,,$m^^
                                        for((t=0;t++<RANDOM%6;))
                                        s+=$m:RANDOM%4:1

                                        printf "$s"



                                        Try it online!



                                        Original answer




                                        Bash, 150 bytes



                                        Have done very little golf bashing and trying to improve my bash, so any comments welcome.





                                        for((i=0;i<$#1-1;i++));do
                                        c=$1:$i:1
                                        n=$1:$((i+1)):1
                                        a=($n $c, $c^ $n, $n^)
                                        shuf -e $a[@] -n "$(shuf -i 1-5 -n 1)"|xargs printf %s
                                        done


                                        Try it online!



                                        Code is straightforward loop through chars setting current c and next n character, then creating an array of the 4 possibilities, repeating one of them so there's exactly 5. Next we shuffle that array, and then choose n elements from it, where n itself is random between 1 and 5.






                                        share|improve this answer











                                        $endgroup$












                                        • $begingroup$
                                          seems it's missing printf %s "$c"
                                          $endgroup$
                                          – Nahuel Fouilleul
                                          Apr 3 at 8:06






                                        • 1




                                          $begingroup$
                                          do and done can be replaced with undocumented and
                                          $endgroup$
                                          – Nahuel Fouilleul
                                          Apr 3 at 8:08










                                        • $begingroup$
                                          with some changes
                                          $endgroup$
                                          – Nahuel Fouilleul
                                          Apr 3 at 8:25











                                        • $begingroup$
                                          @NahuelFouilleul tyvm. nice improvements and nice catch -- i'd somehow missed the requirement always to output the current char.
                                          $endgroup$
                                          – Jonah
                                          Apr 3 at 13:07






                                        • 1




                                          $begingroup$
                                          @roblogic that's clever. tyvm.
                                          $endgroup$
                                          – Jonah
                                          Apr 3 at 21:36















                                        3












                                        $begingroup$


                                        Bash, 121 bytes



                                        -20 bytes thanks to Nahuel



                                        -9 bytes thanks to roblogic





                                        for((i=0;i<$#1;i++))
                                        s=$1:i:1
                                        m=$1:i:2
                                        m=$m,,$m^^
                                        for((t=0;t++<RANDOM%6;))
                                        s+=$m:RANDOM%4:1

                                        printf "$s"



                                        Try it online!



                                        Original answer




                                        Bash, 150 bytes



                                        Have done very little golf bashing and trying to improve my bash, so any comments welcome.





                                        for((i=0;i<$#1-1;i++));do
                                        c=$1:$i:1
                                        n=$1:$((i+1)):1
                                        a=($n $c, $c^ $n, $n^)
                                        shuf -e $a[@] -n "$(shuf -i 1-5 -n 1)"|xargs printf %s
                                        done


                                        Try it online!



                                        Code is straightforward loop through chars setting current c and next n character, then creating an array of the 4 possibilities, repeating one of them so there's exactly 5. Next we shuffle that array, and then choose n elements from it, where n itself is random between 1 and 5.






                                        share|improve this answer











                                        $endgroup$












                                        • $begingroup$
                                          seems it's missing printf %s "$c"
                                          $endgroup$
                                          – Nahuel Fouilleul
                                          Apr 3 at 8:06






                                        • 1




                                          $begingroup$
                                          do and done can be replaced with undocumented and
                                          $endgroup$
                                          – Nahuel Fouilleul
                                          Apr 3 at 8:08










                                        • $begingroup$
                                          with some changes
                                          $endgroup$
                                          – Nahuel Fouilleul
                                          Apr 3 at 8:25











                                        • $begingroup$
                                          @NahuelFouilleul tyvm. nice improvements and nice catch -- i'd somehow missed the requirement always to output the current char.
                                          $endgroup$
                                          – Jonah
                                          Apr 3 at 13:07






                                        • 1




                                          $begingroup$
                                          @roblogic that's clever. tyvm.
                                          $endgroup$
                                          – Jonah
                                          Apr 3 at 21:36













                                        3












                                        3








                                        3





                                        $begingroup$


                                        Bash, 121 bytes



                                        -20 bytes thanks to Nahuel



                                        -9 bytes thanks to roblogic





                                        for((i=0;i<$#1;i++))
                                        s=$1:i:1
                                        m=$1:i:2
                                        m=$m,,$m^^
                                        for((t=0;t++<RANDOM%6;))
                                        s+=$m:RANDOM%4:1

                                        printf "$s"



                                        Try it online!



                                        Original answer




                                        Bash, 150 bytes



                                        Have done very little golf bashing and trying to improve my bash, so any comments welcome.





                                        for((i=0;i<$#1-1;i++));do
                                        c=$1:$i:1
                                        n=$1:$((i+1)):1
                                        a=($n $c, $c^ $n, $n^)
                                        shuf -e $a[@] -n "$(shuf -i 1-5 -n 1)"|xargs printf %s
                                        done


                                        Try it online!



                                        Code is straightforward loop through chars setting current c and next n character, then creating an array of the 4 possibilities, repeating one of them so there's exactly 5. Next we shuffle that array, and then choose n elements from it, where n itself is random between 1 and 5.






                                        share|improve this answer











                                        $endgroup$




                                        Bash, 121 bytes



                                        -20 bytes thanks to Nahuel



                                        -9 bytes thanks to roblogic





                                        for((i=0;i<$#1;i++))
                                        s=$1:i:1
                                        m=$1:i:2
                                        m=$m,,$m^^
                                        for((t=0;t++<RANDOM%6;))
                                        s+=$m:RANDOM%4:1

                                        printf "$s"



                                        Try it online!



                                        Original answer




                                        Bash, 150 bytes



                                        Have done very little golf bashing and trying to improve my bash, so any comments welcome.





                                        for((i=0;i<$#1-1;i++));do
                                        c=$1:$i:1
                                        n=$1:$((i+1)):1
                                        a=($n $c, $c^ $n, $n^)
                                        shuf -e $a[@] -n "$(shuf -i 1-5 -n 1)"|xargs printf %s
                                        done


                                        Try it online!



                                        Code is straightforward loop through chars setting current c and next n character, then creating an array of the 4 possibilities, repeating one of them so there's exactly 5. Next we shuffle that array, and then choose n elements from it, where n itself is random between 1 and 5.







                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited Apr 3 at 21:36

























                                        answered Apr 3 at 4:26









                                        JonahJonah

                                        2,5711017




                                        2,5711017











                                        • $begingroup$
                                          seems it's missing printf %s "$c"
                                          $endgroup$
                                          – Nahuel Fouilleul
                                          Apr 3 at 8:06






                                        • 1




                                          $begingroup$
                                          do and done can be replaced with undocumented and
                                          $endgroup$
                                          – Nahuel Fouilleul
                                          Apr 3 at 8:08










                                        • $begingroup$
                                          with some changes
                                          $endgroup$
                                          – Nahuel Fouilleul
                                          Apr 3 at 8:25











                                        • $begingroup$
                                          @NahuelFouilleul tyvm. nice improvements and nice catch -- i'd somehow missed the requirement always to output the current char.
                                          $endgroup$
                                          – Jonah
                                          Apr 3 at 13:07






                                        • 1




                                          $begingroup$
                                          @roblogic that's clever. tyvm.
                                          $endgroup$
                                          – Jonah
                                          Apr 3 at 21:36
















                                        • $begingroup$
                                          seems it's missing printf %s "$c"
                                          $endgroup$
                                          – Nahuel Fouilleul
                                          Apr 3 at 8:06






                                        • 1




                                          $begingroup$
                                          do and done can be replaced with undocumented and
                                          $endgroup$
                                          – Nahuel Fouilleul
                                          Apr 3 at 8:08










                                        • $begingroup$
                                          with some changes
                                          $endgroup$
                                          – Nahuel Fouilleul
                                          Apr 3 at 8:25











                                        • $begingroup$
                                          @NahuelFouilleul tyvm. nice improvements and nice catch -- i'd somehow missed the requirement always to output the current char.
                                          $endgroup$
                                          – Jonah
                                          Apr 3 at 13:07






                                        • 1




                                          $begingroup$
                                          @roblogic that's clever. tyvm.
                                          $endgroup$
                                          – Jonah
                                          Apr 3 at 21:36















                                        $begingroup$
                                        seems it's missing printf %s "$c"
                                        $endgroup$
                                        – Nahuel Fouilleul
                                        Apr 3 at 8:06




                                        $begingroup$
                                        seems it's missing printf %s "$c"
                                        $endgroup$
                                        – Nahuel Fouilleul
                                        Apr 3 at 8:06




                                        1




                                        1




                                        $begingroup$
                                        do and done can be replaced with undocumented and
                                        $endgroup$
                                        – Nahuel Fouilleul
                                        Apr 3 at 8:08




                                        $begingroup$
                                        do and done can be replaced with undocumented and
                                        $endgroup$
                                        – Nahuel Fouilleul
                                        Apr 3 at 8:08












                                        $begingroup$
                                        with some changes
                                        $endgroup$
                                        – Nahuel Fouilleul
                                        Apr 3 at 8:25





                                        $begingroup$
                                        with some changes
                                        $endgroup$
                                        – Nahuel Fouilleul
                                        Apr 3 at 8:25













                                        $begingroup$
                                        @NahuelFouilleul tyvm. nice improvements and nice catch -- i'd somehow missed the requirement always to output the current char.
                                        $endgroup$
                                        – Jonah
                                        Apr 3 at 13:07




                                        $begingroup$
                                        @NahuelFouilleul tyvm. nice improvements and nice catch -- i'd somehow missed the requirement always to output the current char.
                                        $endgroup$
                                        – Jonah
                                        Apr 3 at 13:07




                                        1




                                        1




                                        $begingroup$
                                        @roblogic that's clever. tyvm.
                                        $endgroup$
                                        – Jonah
                                        Apr 3 at 21:36




                                        $begingroup$
                                        @roblogic that's clever. tyvm.
                                        $endgroup$
                                        – Jonah
                                        Apr 3 at 21:36











                                        2












                                        $begingroup$


                                        Python 2, 107 bytes





                                        f=lambda s:s and s[0]+''.join(sample((s[:2]+s[:2].swapcase())*5,randint(1,5)))+f(s[1:])
                                        from random import*


                                        Try it online!






                                        share|improve this answer









                                        $endgroup$

















                                          2












                                          $begingroup$


                                          Python 2, 107 bytes





                                          f=lambda s:s and s[0]+''.join(sample((s[:2]+s[:2].swapcase())*5,randint(1,5)))+f(s[1:])
                                          from random import*


                                          Try it online!






                                          share|improve this answer









                                          $endgroup$















                                            2












                                            2








                                            2





                                            $begingroup$


                                            Python 2, 107 bytes





                                            f=lambda s:s and s[0]+''.join(sample((s[:2]+s[:2].swapcase())*5,randint(1,5)))+f(s[1:])
                                            from random import*


                                            Try it online!






                                            share|improve this answer









                                            $endgroup$




                                            Python 2, 107 bytes





                                            f=lambda s:s and s[0]+''.join(sample((s[:2]+s[:2].swapcase())*5,randint(1,5)))+f(s[1:])
                                            from random import*


                                            Try it online!







                                            share|improve this answer












                                            share|improve this answer



                                            share|improve this answer










                                            answered Apr 3 at 5:30









                                            Chas BrownChas Brown

                                            5,1691523




                                            5,1691523





















                                                2












                                                $begingroup$


                                                05AB1E, 18 17 bytes



                                                ü)vyн5LΩFyD.š«Ω]J


                                                Inspired by @Giuseppe's Gaia answer.

                                                -1 byte thanks to @Shaggy.



                                                Try it online 10 times or verify all test cases 10 times.



                                                Explanation:





                                                ü) # Create all pairs of the (implicit) input
                                                # i.e. "Hello" → [["H","e"],["e","l"],["l","l"],["l","o"]]
                                                v # Loop over each these pairs `y`:
                                                yн # Push the first character of pair `y`
                                                5LΩ # Get a random integer in the range [1,5]
                                                F # Inner loop that many times:
                                                y # Push pair `y`
                                                D.š« # Duplicate it, swap the cases of the letters, and merge it with `y`
                                                Ω # Then pop and push a random character from this list of four
                                                ]J # After both loops: join the entire stack together to a single string
                                                # (which is output implicitly as result)





                                                share|improve this answer











                                                $endgroup$












                                                • $begingroup$
                                                  I don't know 05AB1E but, instead of INè, could you save anything by pushing the first character of y?
                                                  $endgroup$
                                                  – Shaggy
                                                  Apr 3 at 9:06










                                                • $begingroup$
                                                  @Shaggy Yes, I indeed can.. Thanks! Maybe I should stop golfing for today, I'm a mess, lol..
                                                  $endgroup$
                                                  – Kevin Cruijssen
                                                  Apr 3 at 9:08











                                                • $begingroup$
                                                  You're a mess? ¨vNUy5LΩFy¹X>è«D.š«Ω?
                                                  $endgroup$
                                                  – Magic Octopus Urn
                                                  Apr 3 at 12:52






                                                • 1




                                                  $begingroup$
                                                  @MagicOctopusUrn Although a pretty original approach, I'm afraid it doesn't do the first bullet point of the challenge ("Output the current character."), since the result can start with t, T, or s for input "String" in your program, while it's supposed to always start with the S.
                                                  $endgroup$
                                                  – Kevin Cruijssen
                                                  Apr 3 at 13:03
















                                                2












                                                $begingroup$


                                                05AB1E, 18 17 bytes



                                                ü)vyн5LΩFyD.š«Ω]J


                                                Inspired by @Giuseppe's Gaia answer.

                                                -1 byte thanks to @Shaggy.



                                                Try it online 10 times or verify all test cases 10 times.



                                                Explanation:





                                                ü) # Create all pairs of the (implicit) input
                                                # i.e. "Hello" → [["H","e"],["e","l"],["l","l"],["l","o"]]
                                                v # Loop over each these pairs `y`:
                                                yн # Push the first character of pair `y`
                                                5LΩ # Get a random integer in the range [1,5]
                                                F # Inner loop that many times:
                                                y # Push pair `y`
                                                D.š« # Duplicate it, swap the cases of the letters, and merge it with `y`
                                                Ω # Then pop and push a random character from this list of four
                                                ]J # After both loops: join the entire stack together to a single string
                                                # (which is output implicitly as result)





                                                share|improve this answer











                                                $endgroup$












                                                • $begingroup$
                                                  I don't know 05AB1E but, instead of INè, could you save anything by pushing the first character of y?
                                                  $endgroup$
                                                  – Shaggy
                                                  Apr 3 at 9:06










                                                • $begingroup$
                                                  @Shaggy Yes, I indeed can.. Thanks! Maybe I should stop golfing for today, I'm a mess, lol..
                                                  $endgroup$
                                                  – Kevin Cruijssen
                                                  Apr 3 at 9:08











                                                • $begingroup$
                                                  You're a mess? ¨vNUy5LΩFy¹X>è«D.š«Ω?
                                                  $endgroup$
                                                  – Magic Octopus Urn
                                                  Apr 3 at 12:52






                                                • 1




                                                  $begingroup$
                                                  @MagicOctopusUrn Although a pretty original approach, I'm afraid it doesn't do the first bullet point of the challenge ("Output the current character."), since the result can start with t, T, or s for input "String" in your program, while it's supposed to always start with the S.
                                                  $endgroup$
                                                  – Kevin Cruijssen
                                                  Apr 3 at 13:03














                                                2












                                                2








                                                2





                                                $begingroup$


                                                05AB1E, 18 17 bytes



                                                ü)vyн5LΩFyD.š«Ω]J


                                                Inspired by @Giuseppe's Gaia answer.

                                                -1 byte thanks to @Shaggy.



                                                Try it online 10 times or verify all test cases 10 times.



                                                Explanation:





                                                ü) # Create all pairs of the (implicit) input
                                                # i.e. "Hello" → [["H","e"],["e","l"],["l","l"],["l","o"]]
                                                v # Loop over each these pairs `y`:
                                                yн # Push the first character of pair `y`
                                                5LΩ # Get a random integer in the range [1,5]
                                                F # Inner loop that many times:
                                                y # Push pair `y`
                                                D.š« # Duplicate it, swap the cases of the letters, and merge it with `y`
                                                Ω # Then pop and push a random character from this list of four
                                                ]J # After both loops: join the entire stack together to a single string
                                                # (which is output implicitly as result)





                                                share|improve this answer











                                                $endgroup$




                                                05AB1E, 18 17 bytes



                                                ü)vyн5LΩFyD.š«Ω]J


                                                Inspired by @Giuseppe's Gaia answer.

                                                -1 byte thanks to @Shaggy.



                                                Try it online 10 times or verify all test cases 10 times.



                                                Explanation:





                                                ü) # Create all pairs of the (implicit) input
                                                # i.e. "Hello" → [["H","e"],["e","l"],["l","l"],["l","o"]]
                                                v # Loop over each these pairs `y`:
                                                yн # Push the first character of pair `y`
                                                5LΩ # Get a random integer in the range [1,5]
                                                F # Inner loop that many times:
                                                y # Push pair `y`
                                                D.š« # Duplicate it, swap the cases of the letters, and merge it with `y`
                                                Ω # Then pop and push a random character from this list of four
                                                ]J # After both loops: join the entire stack together to a single string
                                                # (which is output implicitly as result)






                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited Apr 3 at 9:08

























                                                answered Apr 3 at 8:14









                                                Kevin CruijssenKevin Cruijssen

                                                42.3k570217




                                                42.3k570217











                                                • $begingroup$
                                                  I don't know 05AB1E but, instead of INè, could you save anything by pushing the first character of y?
                                                  $endgroup$
                                                  – Shaggy
                                                  Apr 3 at 9:06










                                                • $begingroup$
                                                  @Shaggy Yes, I indeed can.. Thanks! Maybe I should stop golfing for today, I'm a mess, lol..
                                                  $endgroup$
                                                  – Kevin Cruijssen
                                                  Apr 3 at 9:08











                                                • $begingroup$
                                                  You're a mess? ¨vNUy5LΩFy¹X>è«D.š«Ω?
                                                  $endgroup$
                                                  – Magic Octopus Urn
                                                  Apr 3 at 12:52






                                                • 1




                                                  $begingroup$
                                                  @MagicOctopusUrn Although a pretty original approach, I'm afraid it doesn't do the first bullet point of the challenge ("Output the current character."), since the result can start with t, T, or s for input "String" in your program, while it's supposed to always start with the S.
                                                  $endgroup$
                                                  – Kevin Cruijssen
                                                  Apr 3 at 13:03

















                                                • $begingroup$
                                                  I don't know 05AB1E but, instead of INè, could you save anything by pushing the first character of y?
                                                  $endgroup$
                                                  – Shaggy
                                                  Apr 3 at 9:06










                                                • $begingroup$
                                                  @Shaggy Yes, I indeed can.. Thanks! Maybe I should stop golfing for today, I'm a mess, lol..
                                                  $endgroup$
                                                  – Kevin Cruijssen
                                                  Apr 3 at 9:08











                                                • $begingroup$
                                                  You're a mess? ¨vNUy5LΩFy¹X>è«D.š«Ω?
                                                  $endgroup$
                                                  – Magic Octopus Urn
                                                  Apr 3 at 12:52






                                                • 1




                                                  $begingroup$
                                                  @MagicOctopusUrn Although a pretty original approach, I'm afraid it doesn't do the first bullet point of the challenge ("Output the current character."), since the result can start with t, T, or s for input "String" in your program, while it's supposed to always start with the S.
                                                  $endgroup$
                                                  – Kevin Cruijssen
                                                  Apr 3 at 13:03
















                                                $begingroup$
                                                I don't know 05AB1E but, instead of INè, could you save anything by pushing the first character of y?
                                                $endgroup$
                                                – Shaggy
                                                Apr 3 at 9:06




                                                $begingroup$
                                                I don't know 05AB1E but, instead of INè, could you save anything by pushing the first character of y?
                                                $endgroup$
                                                – Shaggy
                                                Apr 3 at 9:06












                                                $begingroup$
                                                @Shaggy Yes, I indeed can.. Thanks! Maybe I should stop golfing for today, I'm a mess, lol..
                                                $endgroup$
                                                – Kevin Cruijssen
                                                Apr 3 at 9:08





                                                $begingroup$
                                                @Shaggy Yes, I indeed can.. Thanks! Maybe I should stop golfing for today, I'm a mess, lol..
                                                $endgroup$
                                                – Kevin Cruijssen
                                                Apr 3 at 9:08













                                                $begingroup$
                                                You're a mess? ¨vNUy5LΩFy¹X>è«D.š«Ω?
                                                $endgroup$
                                                – Magic Octopus Urn
                                                Apr 3 at 12:52




                                                $begingroup$
                                                You're a mess? ¨vNUy5LΩFy¹X>è«D.š«Ω?
                                                $endgroup$
                                                – Magic Octopus Urn
                                                Apr 3 at 12:52




                                                1




                                                1




                                                $begingroup$
                                                @MagicOctopusUrn Although a pretty original approach, I'm afraid it doesn't do the first bullet point of the challenge ("Output the current character."), since the result can start with t, T, or s for input "String" in your program, while it's supposed to always start with the S.
                                                $endgroup$
                                                – Kevin Cruijssen
                                                Apr 3 at 13:03





                                                $begingroup$
                                                @MagicOctopusUrn Although a pretty original approach, I'm afraid it doesn't do the first bullet point of the challenge ("Output the current character."), since the result can start with t, T, or s for input "String" in your program, while it's supposed to always start with the S.
                                                $endgroup$
                                                – Kevin Cruijssen
                                                Apr 3 at 13:03












                                                1












                                                $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$

















                                                  1












                                                  $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$















                                                    1












                                                    1








                                                    1





                                                    $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 Apr 2 at 23:58









                                                    NeilNeil

                                                    82.6k745179




                                                    82.6k745179





















                                                        1












                                                        $begingroup$

                                                        perl 5 (-p), 77 bytes



                                                        s/(.)(?=(.))/$x=$1;'$x.=substr"U$1$2L$1$2",4*rand,1;'x(1+5*rand)/gee;s/.$//


                                                        TIO






                                                        share|improve this answer









                                                        $endgroup$












                                                        • $begingroup$
                                                          You can save 4 bytes by using $& instead of $1, and chop + -l instead of s/.$//
                                                          $endgroup$
                                                          – Dada
                                                          2 days ago















                                                        1












                                                        $begingroup$

                                                        perl 5 (-p), 77 bytes



                                                        s/(.)(?=(.))/$x=$1;'$x.=substr"U$1$2L$1$2",4*rand,1;'x(1+5*rand)/gee;s/.$//


                                                        TIO






                                                        share|improve this answer









                                                        $endgroup$












                                                        • $begingroup$
                                                          You can save 4 bytes by using $& instead of $1, and chop + -l instead of s/.$//
                                                          $endgroup$
                                                          – Dada
                                                          2 days ago













                                                        1












                                                        1








                                                        1





                                                        $begingroup$

                                                        perl 5 (-p), 77 bytes



                                                        s/(.)(?=(.))/$x=$1;'$x.=substr"U$1$2L$1$2",4*rand,1;'x(1+5*rand)/gee;s/.$//


                                                        TIO






                                                        share|improve this answer









                                                        $endgroup$



                                                        perl 5 (-p), 77 bytes



                                                        s/(.)(?=(.))/$x=$1;'$x.=substr"U$1$2L$1$2",4*rand,1;'x(1+5*rand)/gee;s/.$//


                                                        TIO







                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered Apr 3 at 8:01









                                                        Nahuel FouilleulNahuel Fouilleul

                                                        3,015211




                                                        3,015211











                                                        • $begingroup$
                                                          You can save 4 bytes by using $& instead of $1, and chop + -l instead of s/.$//
                                                          $endgroup$
                                                          – Dada
                                                          2 days ago
















                                                        • $begingroup$
                                                          You can save 4 bytes by using $& instead of $1, and chop + -l instead of s/.$//
                                                          $endgroup$
                                                          – Dada
                                                          2 days ago















                                                        $begingroup$
                                                        You can save 4 bytes by using $& instead of $1, and chop + -l instead of s/.$//
                                                        $endgroup$
                                                        – Dada
                                                        2 days ago




                                                        $begingroup$
                                                        You can save 4 bytes by using $& instead of $1, and chop + -l instead of s/.$//
                                                        $endgroup$
                                                        – Dada
                                                        2 days ago











                                                        1












                                                        $begingroup$


                                                        Japt -P, 14 bytes



                                                        äÈ+Zu pv ö5ö Ä


                                                        Try it



                                                        äÈ+Zu pv ö5ö Ä :Implicit input of string
                                                        ä :Take each consectutive pair of characters
                                                        È :Pass them through the following function as Z
                                                        + : Append to the first character of the pair
                                                        Zu : Uppercase Z
                                                        p : Append
                                                        v : Lowercase
                                                        ö : Get X random characters, where X is
                                                        5ö : Random number in the range [0,5)
                                                        Ä : Plus 1
                                                        :Implicitly join and output





                                                        share|improve this answer











                                                        $endgroup$

















                                                          1












                                                          $begingroup$


                                                          Japt -P, 14 bytes



                                                          äÈ+Zu pv ö5ö Ä


                                                          Try it



                                                          äÈ+Zu pv ö5ö Ä :Implicit input of string
                                                          ä :Take each consectutive pair of characters
                                                          È :Pass them through the following function as Z
                                                          + : Append to the first character of the pair
                                                          Zu : Uppercase Z
                                                          p : Append
                                                          v : Lowercase
                                                          ö : Get X random characters, where X is
                                                          5ö : Random number in the range [0,5)
                                                          Ä : Plus 1
                                                          :Implicitly join and output





                                                          share|improve this answer











                                                          $endgroup$















                                                            1












                                                            1








                                                            1





                                                            $begingroup$


                                                            Japt -P, 14 bytes



                                                            äÈ+Zu pv ö5ö Ä


                                                            Try it



                                                            äÈ+Zu pv ö5ö Ä :Implicit input of string
                                                            ä :Take each consectutive pair of characters
                                                            È :Pass them through the following function as Z
                                                            + : Append to the first character of the pair
                                                            Zu : Uppercase Z
                                                            p : Append
                                                            v : Lowercase
                                                            ö : Get X random characters, where X is
                                                            5ö : Random number in the range [0,5)
                                                            Ä : Plus 1
                                                            :Implicitly join and output





                                                            share|improve this answer











                                                            $endgroup$




                                                            Japt -P, 14 bytes



                                                            äÈ+Zu pv ö5ö Ä


                                                            Try it



                                                            äÈ+Zu pv ö5ö Ä :Implicit input of string
                                                            ä :Take each consectutive pair of characters
                                                            È :Pass them through the following function as Z
                                                            + : Append to the first character of the pair
                                                            Zu : Uppercase Z
                                                            p : Append
                                                            v : Lowercase
                                                            ö : Get X random characters, where X is
                                                            5ö : Random number in the range [0,5)
                                                            Ä : Plus 1
                                                            :Implicitly join and output






                                                            share|improve this answer














                                                            share|improve this answer



                                                            share|improve this answer








                                                            edited Apr 3 at 14:07

























                                                            answered Apr 3 at 10:07









                                                            ShaggyShaggy

                                                            18.8k21768




                                                            18.8k21768





















                                                                1












                                                                $begingroup$


                                                                Python 3, 167 bytes





                                                                from random import*;c=choice
                                                                def f(s):
                                                                i=0;r=""
                                                                for i in range(len(s)-1):
                                                                r+=s[i]
                                                                for j in range(randrange(5)):r+=c([str.upper,str.lower])(c(s[i:i+2]))
                                                                return r


                                                                Try it online!






                                                                share|improve this answer









                                                                $endgroup$

















                                                                  1












                                                                  $begingroup$


                                                                  Python 3, 167 bytes





                                                                  from random import*;c=choice
                                                                  def f(s):
                                                                  i=0;r=""
                                                                  for i in range(len(s)-1):
                                                                  r+=s[i]
                                                                  for j in range(randrange(5)):r+=c([str.upper,str.lower])(c(s[i:i+2]))
                                                                  return r


                                                                  Try it online!






                                                                  share|improve this answer









                                                                  $endgroup$















                                                                    1












                                                                    1








                                                                    1





                                                                    $begingroup$


                                                                    Python 3, 167 bytes





                                                                    from random import*;c=choice
                                                                    def f(s):
                                                                    i=0;r=""
                                                                    for i in range(len(s)-1):
                                                                    r+=s[i]
                                                                    for j in range(randrange(5)):r+=c([str.upper,str.lower])(c(s[i:i+2]))
                                                                    return r


                                                                    Try it online!






                                                                    share|improve this answer









                                                                    $endgroup$




                                                                    Python 3, 167 bytes





                                                                    from random import*;c=choice
                                                                    def f(s):
                                                                    i=0;r=""
                                                                    for i in range(len(s)-1):
                                                                    r+=s[i]
                                                                    for j in range(randrange(5)):r+=c([str.upper,str.lower])(c(s[i:i+2]))
                                                                    return r


                                                                    Try it online!







                                                                    share|improve this answer












                                                                    share|improve this answer



                                                                    share|improve this answer










                                                                    answered Apr 3 at 15:27









                                                                    Sara JSara J

                                                                    555210




                                                                    555210





















                                                                        1












                                                                        $begingroup$


                                                                        Jelly, 14 bytes



                                                                        ;;;Œs$Xɗ¥5X¤¡Ɲ


                                                                        Try it online!



                                                                        Explanation



                                                                         Ɲ | For each overlapping pair of letters
                                                                        ; | Join the first letter to...
                                                                        5X¤¡ | Between 1 and 5 repetitions of...
                                                                        Xɗ¥ | A randomly selected character from...
                                                                        ;;Œs$ | A list of the two letters and the swapped case versions of both





                                                                        share|improve this answer











                                                                        $endgroup$

















                                                                          1












                                                                          $begingroup$


                                                                          Jelly, 14 bytes



                                                                          ;;;Œs$Xɗ¥5X¤¡Ɲ


                                                                          Try it online!



                                                                          Explanation



                                                                           Ɲ | For each overlapping pair of letters
                                                                          ; | Join the first letter to...
                                                                          5X¤¡ | Between 1 and 5 repetitions of...
                                                                          Xɗ¥ | A randomly selected character from...
                                                                          ;;Œs$ | A list of the two letters and the swapped case versions of both





                                                                          share|improve this answer











                                                                          $endgroup$















                                                                            1












                                                                            1








                                                                            1





                                                                            $begingroup$


                                                                            Jelly, 14 bytes



                                                                            ;;;Œs$Xɗ¥5X¤¡Ɲ


                                                                            Try it online!



                                                                            Explanation



                                                                             Ɲ | For each overlapping pair of letters
                                                                            ; | Join the first letter to...
                                                                            5X¤¡ | Between 1 and 5 repetitions of...
                                                                            Xɗ¥ | A randomly selected character from...
                                                                            ;;Œs$ | A list of the two letters and the swapped case versions of both





                                                                            share|improve this answer











                                                                            $endgroup$




                                                                            Jelly, 14 bytes



                                                                            ;;;Œs$Xɗ¥5X¤¡Ɲ


                                                                            Try it online!



                                                                            Explanation



                                                                             Ɲ | For each overlapping pair of letters
                                                                            ; | Join the first letter to...
                                                                            5X¤¡ | Between 1 and 5 repetitions of...
                                                                            Xɗ¥ | A randomly selected character from...
                                                                            ;;Œs$ | A list of the two letters and the swapped case versions of both






                                                                            share|improve this answer














                                                                            share|improve this answer



                                                                            share|improve this answer








                                                                            edited Apr 3 at 16:58

























                                                                            answered Apr 3 at 6:25









                                                                            Nick KennedyNick Kennedy

                                                                            1,32649




                                                                            1,32649





















                                                                                1












                                                                                $begingroup$

                                                                                C(GCC) 175 162 bytes



                                                                                -12 bytes from LambdaBeta



                                                                                f(s,S,i,r,a)char*s,*S,*i;srand(time(0));for(i=S;*(s+1);++s)a>64&a<91?a^32:a:a)a=rand()&1?*s:*(s+1);*i=0;


                                                                                Try it online






                                                                                share|improve this answer











                                                                                $endgroup$












                                                                                • $begingroup$
                                                                                  I don't think you need the 0 in the first line.
                                                                                  $endgroup$
                                                                                  – LambdaBeta
                                                                                  Apr 3 at 21:28










                                                                                • $begingroup$
                                                                                  Also can save a lot of characters by taking the buffer S as a parameter and adding your variables to the argument list: Try it online!
                                                                                  $endgroup$
                                                                                  – LambdaBeta
                                                                                  Apr 3 at 21:31










                                                                                • $begingroup$
                                                                                  @LambdaBeta turns out you are right about the 0, which made it not worth it to have the #define anymore
                                                                                  $endgroup$
                                                                                  – rtpax
                                                                                  2 days ago















                                                                                1












                                                                                $begingroup$

                                                                                C(GCC) 175 162 bytes



                                                                                -12 bytes from LambdaBeta



                                                                                f(s,S,i,r,a)char*s,*S,*i;srand(time(0));for(i=S;*(s+1);++s)a>64&a<91?a^32:a:a)a=rand()&1?*s:*(s+1);*i=0;


                                                                                Try it online






                                                                                share|improve this answer











                                                                                $endgroup$












                                                                                • $begingroup$
                                                                                  I don't think you need the 0 in the first line.
                                                                                  $endgroup$
                                                                                  – LambdaBeta
                                                                                  Apr 3 at 21:28










                                                                                • $begingroup$
                                                                                  Also can save a lot of characters by taking the buffer S as a parameter and adding your variables to the argument list: Try it online!
                                                                                  $endgroup$
                                                                                  – LambdaBeta
                                                                                  Apr 3 at 21:31










                                                                                • $begingroup$
                                                                                  @LambdaBeta turns out you are right about the 0, which made it not worth it to have the #define anymore
                                                                                  $endgroup$
                                                                                  – rtpax
                                                                                  2 days ago













                                                                                1












                                                                                1








                                                                                1





                                                                                $begingroup$

                                                                                C(GCC) 175 162 bytes



                                                                                -12 bytes from LambdaBeta



                                                                                f(s,S,i,r,a)char*s,*S,*i;srand(time(0));for(i=S;*(s+1);++s)a>64&a<91?a^32:a:a)a=rand()&1?*s:*(s+1);*i=0;


                                                                                Try it online






                                                                                share|improve this answer











                                                                                $endgroup$



                                                                                C(GCC) 175 162 bytes



                                                                                -12 bytes from LambdaBeta



                                                                                f(s,S,i,r,a)char*s,*S,*i;srand(time(0));for(i=S;*(s+1);++s)a>64&a<91?a^32:a:a)a=rand()&1?*s:*(s+1);*i=0;


                                                                                Try it online







                                                                                share|improve this answer














                                                                                share|improve this answer



                                                                                share|improve this answer








                                                                                edited 2 days ago

























                                                                                answered Apr 3 at 18:02









                                                                                rtpaxrtpax

                                                                                3165




                                                                                3165











                                                                                • $begingroup$
                                                                                  I don't think you need the 0 in the first line.
                                                                                  $endgroup$
                                                                                  – LambdaBeta
                                                                                  Apr 3 at 21:28










                                                                                • $begingroup$
                                                                                  Also can save a lot of characters by taking the buffer S as a parameter and adding your variables to the argument list: Try it online!
                                                                                  $endgroup$
                                                                                  – LambdaBeta
                                                                                  Apr 3 at 21:31










                                                                                • $begingroup$
                                                                                  @LambdaBeta turns out you are right about the 0, which made it not worth it to have the #define anymore
                                                                                  $endgroup$
                                                                                  – rtpax
                                                                                  2 days ago
















                                                                                • $begingroup$
                                                                                  I don't think you need the 0 in the first line.
                                                                                  $endgroup$
                                                                                  – LambdaBeta
                                                                                  Apr 3 at 21:28










                                                                                • $begingroup$
                                                                                  Also can save a lot of characters by taking the buffer S as a parameter and adding your variables to the argument list: Try it online!
                                                                                  $endgroup$
                                                                                  – LambdaBeta
                                                                                  Apr 3 at 21:31










                                                                                • $begingroup$
                                                                                  @LambdaBeta turns out you are right about the 0, which made it not worth it to have the #define anymore
                                                                                  $endgroup$
                                                                                  – rtpax
                                                                                  2 days ago















                                                                                $begingroup$
                                                                                I don't think you need the 0 in the first line.
                                                                                $endgroup$
                                                                                – LambdaBeta
                                                                                Apr 3 at 21:28




                                                                                $begingroup$
                                                                                I don't think you need the 0 in the first line.
                                                                                $endgroup$
                                                                                – LambdaBeta
                                                                                Apr 3 at 21:28












                                                                                $begingroup$
                                                                                Also can save a lot of characters by taking the buffer S as a parameter and adding your variables to the argument list: Try it online!
                                                                                $endgroup$
                                                                                – LambdaBeta
                                                                                Apr 3 at 21:31




                                                                                $begingroup$
                                                                                Also can save a lot of characters by taking the buffer S as a parameter and adding your variables to the argument list: Try it online!
                                                                                $endgroup$
                                                                                – LambdaBeta
                                                                                Apr 3 at 21:31












                                                                                $begingroup$
                                                                                @LambdaBeta turns out you are right about the 0, which made it not worth it to have the #define anymore
                                                                                $endgroup$
                                                                                – rtpax
                                                                                2 days ago




                                                                                $begingroup$
                                                                                @LambdaBeta turns out you are right about the 0, which made it not worth it to have the #define anymore
                                                                                $endgroup$
                                                                                – rtpax
                                                                                2 days ago











                                                                                0












                                                                                $begingroup$


                                                                                Scala 2.12.8, 214 bytes



                                                                                Golfed version:



                                                                                val r=scala.util.Random;println(readLine.toList.sliding(2).flatMapcase a :: b :: Nil=>(a +: (0 to r.nextInt(5)).map_=>((c: Char)=>if(r.nextBoolean)c.toUpper else c.toLower)(if(r.nextBoolean)a else b)).mkString)


                                                                                Golfed with newlines and indents:



                                                                                val r=scala.util.Random
                                                                                println(readLine.toList.sliding(2).flatMap
                                                                                case a :: b :: Nil=>
                                                                                (a +: (0 to r.nextInt(5)).map_=>
                                                                                ((c: Char)=>if(r.nextBoolean)c.toUpper else c.toLower)(if(r.nextBoolean)a else b)
                                                                                )
                                                                                .mkString)


                                                                                Ungolfed:



                                                                                import scala.io.StdIn
                                                                                import scala.util.Random

                                                                                def gobble(input: String): String =
                                                                                input.toList.sliding(2).flatMap
                                                                                case thisChar :: nextChar :: Nil =>
                                                                                val numberOfAdditions = Random.nextInt(5)
                                                                                (thisChar +: (0 to numberOfAdditions).map _ =>
                                                                                val char = if(Random.nextBoolean) thisChar else nextChar
                                                                                val cc = if(Random.nextBoolean) char.toUpper else char.ToLower
                                                                                cc
                                                                                )
                                                                                .mkString


                                                                                println(gobble(StdIn.readLine()))





                                                                                share|improve this answer









                                                                                $endgroup$








                                                                                • 1




                                                                                  $begingroup$
                                                                                  No way to turn a :: b :: Nil into a::b::Nil? Same for a :+, a:+() or a.:+() might work
                                                                                  $endgroup$
                                                                                  – Ven
                                                                                  2 days ago










                                                                                • $begingroup$
                                                                                  @Ven a::b::Nil causes a compile error. +: is a method defined on the list, so it might save space by getting rid of the outer parens?
                                                                                  $endgroup$
                                                                                  – Soren
                                                                                  2 days ago











                                                                                • $begingroup$
                                                                                  You only have only one elem here so it’s not autotupling anyway
                                                                                  $endgroup$
                                                                                  – Ven
                                                                                  2 days ago















                                                                                0












                                                                                $begingroup$


                                                                                Scala 2.12.8, 214 bytes



                                                                                Golfed version:



                                                                                val r=scala.util.Random;println(readLine.toList.sliding(2).flatMapcase a :: b :: Nil=>(a +: (0 to r.nextInt(5)).map_=>((c: Char)=>if(r.nextBoolean)c.toUpper else c.toLower)(if(r.nextBoolean)a else b)).mkString)


                                                                                Golfed with newlines and indents:



                                                                                val r=scala.util.Random
                                                                                println(readLine.toList.sliding(2).flatMap
                                                                                case a :: b :: Nil=>
                                                                                (a +: (0 to r.nextInt(5)).map_=>
                                                                                ((c: Char)=>if(r.nextBoolean)c.toUpper else c.toLower)(if(r.nextBoolean)a else b)
                                                                                )
                                                                                .mkString)


                                                                                Ungolfed:



                                                                                import scala.io.StdIn
                                                                                import scala.util.Random

                                                                                def gobble(input: String): String =
                                                                                input.toList.sliding(2).flatMap
                                                                                case thisChar :: nextChar :: Nil =>
                                                                                val numberOfAdditions = Random.nextInt(5)
                                                                                (thisChar +: (0 to numberOfAdditions).map _ =>
                                                                                val char = if(Random.nextBoolean) thisChar else nextChar
                                                                                val cc = if(Random.nextBoolean) char.toUpper else char.ToLower
                                                                                cc
                                                                                )
                                                                                .mkString


                                                                                println(gobble(StdIn.readLine()))





                                                                                share|improve this answer









                                                                                $endgroup$








                                                                                • 1




                                                                                  $begingroup$
                                                                                  No way to turn a :: b :: Nil into a::b::Nil? Same for a :+, a:+() or a.:+() might work
                                                                                  $endgroup$
                                                                                  – Ven
                                                                                  2 days ago










                                                                                • $begingroup$
                                                                                  @Ven a::b::Nil causes a compile error. +: is a method defined on the list, so it might save space by getting rid of the outer parens?
                                                                                  $endgroup$
                                                                                  – Soren
                                                                                  2 days ago











                                                                                • $begingroup$
                                                                                  You only have only one elem here so it’s not autotupling anyway
                                                                                  $endgroup$
                                                                                  – Ven
                                                                                  2 days ago













                                                                                0












                                                                                0








                                                                                0





                                                                                $begingroup$


                                                                                Scala 2.12.8, 214 bytes



                                                                                Golfed version:



                                                                                val r=scala.util.Random;println(readLine.toList.sliding(2).flatMapcase a :: b :: Nil=>(a +: (0 to r.nextInt(5)).map_=>((c: Char)=>if(r.nextBoolean)c.toUpper else c.toLower)(if(r.nextBoolean)a else b)).mkString)


                                                                                Golfed with newlines and indents:



                                                                                val r=scala.util.Random
                                                                                println(readLine.toList.sliding(2).flatMap
                                                                                case a :: b :: Nil=>
                                                                                (a +: (0 to r.nextInt(5)).map_=>
                                                                                ((c: Char)=>if(r.nextBoolean)c.toUpper else c.toLower)(if(r.nextBoolean)a else b)
                                                                                )
                                                                                .mkString)


                                                                                Ungolfed:



                                                                                import scala.io.StdIn
                                                                                import scala.util.Random

                                                                                def gobble(input: String): String =
                                                                                input.toList.sliding(2).flatMap
                                                                                case thisChar :: nextChar :: Nil =>
                                                                                val numberOfAdditions = Random.nextInt(5)
                                                                                (thisChar +: (0 to numberOfAdditions).map _ =>
                                                                                val char = if(Random.nextBoolean) thisChar else nextChar
                                                                                val cc = if(Random.nextBoolean) char.toUpper else char.ToLower
                                                                                cc
                                                                                )
                                                                                .mkString


                                                                                println(gobble(StdIn.readLine()))





                                                                                share|improve this answer









                                                                                $endgroup$




                                                                                Scala 2.12.8, 214 bytes



                                                                                Golfed version:



                                                                                val r=scala.util.Random;println(readLine.toList.sliding(2).flatMapcase a :: b :: Nil=>(a +: (0 to r.nextInt(5)).map_=>((c: Char)=>if(r.nextBoolean)c.toUpper else c.toLower)(if(r.nextBoolean)a else b)).mkString)


                                                                                Golfed with newlines and indents:



                                                                                val r=scala.util.Random
                                                                                println(readLine.toList.sliding(2).flatMap
                                                                                case a :: b :: Nil=>
                                                                                (a +: (0 to r.nextInt(5)).map_=>
                                                                                ((c: Char)=>if(r.nextBoolean)c.toUpper else c.toLower)(if(r.nextBoolean)a else b)
                                                                                )
                                                                                .mkString)


                                                                                Ungolfed:



                                                                                import scala.io.StdIn
                                                                                import scala.util.Random

                                                                                def gobble(input: String): String =
                                                                                input.toList.sliding(2).flatMap
                                                                                case thisChar :: nextChar :: Nil =>
                                                                                val numberOfAdditions = Random.nextInt(5)
                                                                                (thisChar +: (0 to numberOfAdditions).map _ =>
                                                                                val char = if(Random.nextBoolean) thisChar else nextChar
                                                                                val cc = if(Random.nextBoolean) char.toUpper else char.ToLower
                                                                                cc
                                                                                )
                                                                                .mkString


                                                                                println(gobble(StdIn.readLine()))






                                                                                share|improve this answer












                                                                                share|improve this answer



                                                                                share|improve this answer










                                                                                answered Apr 3 at 22:32









                                                                                SorenSoren

                                                                                2008




                                                                                2008







                                                                                • 1




                                                                                  $begingroup$
                                                                                  No way to turn a :: b :: Nil into a::b::Nil? Same for a :+, a:+() or a.:+() might work
                                                                                  $endgroup$
                                                                                  – Ven
                                                                                  2 days ago










                                                                                • $begingroup$
                                                                                  @Ven a::b::Nil causes a compile error. +: is a method defined on the list, so it might save space by getting rid of the outer parens?
                                                                                  $endgroup$
                                                                                  – Soren
                                                                                  2 days ago











                                                                                • $begingroup$
                                                                                  You only have only one elem here so it’s not autotupling anyway
                                                                                  $endgroup$
                                                                                  – Ven
                                                                                  2 days ago












                                                                                • 1




                                                                                  $begingroup$
                                                                                  No way to turn a :: b :: Nil into a::b::Nil? Same for a :+, a:+() or a.:+() might work
                                                                                  $endgroup$
                                                                                  – Ven
                                                                                  2 days ago










                                                                                • $begingroup$
                                                                                  @Ven a::b::Nil causes a compile error. +: is a method defined on the list, so it might save space by getting rid of the outer parens?
                                                                                  $endgroup$
                                                                                  – Soren
                                                                                  2 days ago











                                                                                • $begingroup$
                                                                                  You only have only one elem here so it’s not autotupling anyway
                                                                                  $endgroup$
                                                                                  – Ven
                                                                                  2 days ago







                                                                                1




                                                                                1




                                                                                $begingroup$
                                                                                No way to turn a :: b :: Nil into a::b::Nil? Same for a :+, a:+() or a.:+() might work
                                                                                $endgroup$
                                                                                – Ven
                                                                                2 days ago




                                                                                $begingroup$
                                                                                No way to turn a :: b :: Nil into a::b::Nil? Same for a :+, a:+() or a.:+() might work
                                                                                $endgroup$
                                                                                – Ven
                                                                                2 days ago












                                                                                $begingroup$
                                                                                @Ven a::b::Nil causes a compile error. +: is a method defined on the list, so it might save space by getting rid of the outer parens?
                                                                                $endgroup$
                                                                                – Soren
                                                                                2 days ago





                                                                                $begingroup$
                                                                                @Ven a::b::Nil causes a compile error. +: is a method defined on the list, so it might save space by getting rid of the outer parens?
                                                                                $endgroup$
                                                                                – Soren
                                                                                2 days ago













                                                                                $begingroup$
                                                                                You only have only one elem here so it’s not autotupling anyway
                                                                                $endgroup$
                                                                                – Ven
                                                                                2 days ago




                                                                                $begingroup$
                                                                                You only have only one elem here so it’s not autotupling anyway
                                                                                $endgroup$
                                                                                – Ven
                                                                                2 days ago











                                                                                0












                                                                                $begingroup$


                                                                                Perl 5 -n, 61 bytes





                                                                                s/.(?=(.))/print$&,map(maplc,uc$&,$1)[rand 4]0..rand 5/ge


                                                                                Try it online!






                                                                                share|improve this answer









                                                                                $endgroup$

















                                                                                  0












                                                                                  $begingroup$


                                                                                  Perl 5 -n, 61 bytes





                                                                                  s/.(?=(.))/print$&,map(maplc,uc$&,$1)[rand 4]0..rand 5/ge


                                                                                  Try it online!






                                                                                  share|improve this answer









                                                                                  $endgroup$















                                                                                    0












                                                                                    0








                                                                                    0





                                                                                    $begingroup$


                                                                                    Perl 5 -n, 61 bytes





                                                                                    s/.(?=(.))/print$&,map(maplc,uc$&,$1)[rand 4]0..rand 5/ge


                                                                                    Try it online!






                                                                                    share|improve this answer









                                                                                    $endgroup$




                                                                                    Perl 5 -n, 61 bytes





                                                                                    s/.(?=(.))/print$&,map(maplc,uc$&,$1)[rand 4]0..rand 5/ge


                                                                                    Try it online!







                                                                                    share|improve this answer












                                                                                    share|improve this answer



                                                                                    share|improve this answer










                                                                                    answered 2 days ago









                                                                                    DadaDada

                                                                                    7,77411140




                                                                                    7,77411140





















                                                                                        0












                                                                                        $begingroup$


                                                                                        C# (Visual C# Interactive Compiler), 236 213 209 bytes





                                                                                        a=>int i=0,j;var m=new Random();var s="";var c = a.Select(x=>Char.IsLetter(x)?(char)(x^32):x).ToArray();for(;i<a.Length-1;i++)for(j=m.Next(1,5);j-->0;)s+=new[]a[i],c[i],a[i+1],c[i+1][m.Next(0,3)];return s;


                                                                                        Try it online!






                                                                                        share|improve this answer











                                                                                        $endgroup$












                                                                                        • $begingroup$
                                                                                          Does not work with non-alphanumeric characters. char b=a[0] -> var b=a[0], extra space in declaration of d in for-loop
                                                                                          $endgroup$
                                                                                          – Embodiment of Ignorance
                                                                                          2 days ago















                                                                                        0












                                                                                        $begingroup$


                                                                                        C# (Visual C# Interactive Compiler), 236 213 209 bytes





                                                                                        a=>int i=0,j;var m=new Random();var s="";var c = a.Select(x=>Char.IsLetter(x)?(char)(x^32):x).ToArray();for(;i<a.Length-1;i++)for(j=m.Next(1,5);j-->0;)s+=new[]a[i],c[i],a[i+1],c[i+1][m.Next(0,3)];return s;


                                                                                        Try it online!






                                                                                        share|improve this answer











                                                                                        $endgroup$












                                                                                        • $begingroup$
                                                                                          Does not work with non-alphanumeric characters. char b=a[0] -> var b=a[0], extra space in declaration of d in for-loop
                                                                                          $endgroup$
                                                                                          – Embodiment of Ignorance
                                                                                          2 days ago













                                                                                        0












                                                                                        0








                                                                                        0





                                                                                        $begingroup$


                                                                                        C# (Visual C# Interactive Compiler), 236 213 209 bytes





                                                                                        a=>int i=0,j;var m=new Random();var s="";var c = a.Select(x=>Char.IsLetter(x)?(char)(x^32):x).ToArray();for(;i<a.Length-1;i++)for(j=m.Next(1,5);j-->0;)s+=new[]a[i],c[i],a[i+1],c[i+1][m.Next(0,3)];return s;


                                                                                        Try it online!






                                                                                        share|improve this answer











                                                                                        $endgroup$




                                                                                        C# (Visual C# Interactive Compiler), 236 213 209 bytes





                                                                                        a=>int i=0,j;var m=new Random();var s="";var c = a.Select(x=>Char.IsLetter(x)?(char)(x^32):x).ToArray();for(;i<a.Length-1;i++)for(j=m.Next(1,5);j-->0;)s+=new[]a[i],c[i],a[i+1],c[i+1][m.Next(0,3)];return s;


                                                                                        Try it online!







                                                                                        share|improve this answer














                                                                                        share|improve this answer



                                                                                        share|improve this answer








                                                                                        edited 2 days ago

























                                                                                        answered Apr 3 at 16:10









                                                                                        Expired DataExpired Data

                                                                                        52313




                                                                                        52313











                                                                                        • $begingroup$
                                                                                          Does not work with non-alphanumeric characters. char b=a[0] -> var b=a[0], extra space in declaration of d in for-loop
                                                                                          $endgroup$
                                                                                          – Embodiment of Ignorance
                                                                                          2 days ago
















                                                                                        • $begingroup$
                                                                                          Does not work with non-alphanumeric characters. char b=a[0] -> var b=a[0], extra space in declaration of d in for-loop
                                                                                          $endgroup$
                                                                                          – Embodiment of Ignorance
                                                                                          2 days ago















                                                                                        $begingroup$
                                                                                        Does not work with non-alphanumeric characters. char b=a[0] -> var b=a[0], extra space in declaration of d in for-loop
                                                                                        $endgroup$
                                                                                        – Embodiment of Ignorance
                                                                                        2 days ago




                                                                                        $begingroup$
                                                                                        Does not work with non-alphanumeric characters. char b=a[0] -> var b=a[0], extra space in declaration of d in for-loop
                                                                                        $endgroup$
                                                                                        – Embodiment of Ignorance
                                                                                        2 days ago











                                                                                        0












                                                                                        $begingroup$

                                                                                        T-SQL query, 286 bytes



                                                                                        DECLARE @ char(999)='String'

                                                                                        SELECT @=stuff(@,n+2,0,s)FROM(SELECT
                                                                                        top 999*,substring(lower(c)+upper(c),abs(v%4)+1,1)s
                                                                                        FROM(SELECT*,number n,substring(@,number+1,2)c,cast(newid()as varbinary)v
                                                                                        FROM(values(1),(2),(3),(4),(5))F(h),spt_values)D
                                                                                        WHERE'P'=type and n<len(@)-1and h>v%3+2ORDER
                                                                                        BY-n)E
                                                                                        PRINT LEFT(@,len(@)-1)


                                                                                        Try it online unfortunately the online version always show the same result for the same varchar, unlike MS SQL Server Management Studio






                                                                                        share|improve this answer











                                                                                        $endgroup$

















                                                                                          0












                                                                                          $begingroup$

                                                                                          T-SQL query, 286 bytes



                                                                                          DECLARE @ char(999)='String'

                                                                                          SELECT @=stuff(@,n+2,0,s)FROM(SELECT
                                                                                          top 999*,substring(lower(c)+upper(c),abs(v%4)+1,1)s
                                                                                          FROM(SELECT*,number n,substring(@,number+1,2)c,cast(newid()as varbinary)v
                                                                                          FROM(values(1),(2),(3),(4),(5))F(h),spt_values)D
                                                                                          WHERE'P'=type and n<len(@)-1and h>v%3+2ORDER
                                                                                          BY-n)E
                                                                                          PRINT LEFT(@,len(@)-1)


                                                                                          Try it online unfortunately the online version always show the same result for the same varchar, unlike MS SQL Server Management Studio






                                                                                          share|improve this answer











                                                                                          $endgroup$















                                                                                            0












                                                                                            0








                                                                                            0





                                                                                            $begingroup$

                                                                                            T-SQL query, 286 bytes



                                                                                            DECLARE @ char(999)='String'

                                                                                            SELECT @=stuff(@,n+2,0,s)FROM(SELECT
                                                                                            top 999*,substring(lower(c)+upper(c),abs(v%4)+1,1)s
                                                                                            FROM(SELECT*,number n,substring(@,number+1,2)c,cast(newid()as varbinary)v
                                                                                            FROM(values(1),(2),(3),(4),(5))F(h),spt_values)D
                                                                                            WHERE'P'=type and n<len(@)-1and h>v%3+2ORDER
                                                                                            BY-n)E
                                                                                            PRINT LEFT(@,len(@)-1)


                                                                                            Try it online unfortunately the online version always show the same result for the same varchar, unlike MS SQL Server Management Studio






                                                                                            share|improve this answer











                                                                                            $endgroup$



                                                                                            T-SQL query, 286 bytes



                                                                                            DECLARE @ char(999)='String'

                                                                                            SELECT @=stuff(@,n+2,0,s)FROM(SELECT
                                                                                            top 999*,substring(lower(c)+upper(c),abs(v%4)+1,1)s
                                                                                            FROM(SELECT*,number n,substring(@,number+1,2)c,cast(newid()as varbinary)v
                                                                                            FROM(values(1),(2),(3),(4),(5))F(h),spt_values)D
                                                                                            WHERE'P'=type and n<len(@)-1and h>v%3+2ORDER
                                                                                            BY-n)E
                                                                                            PRINT LEFT(@,len(@)-1)


                                                                                            Try it online unfortunately the online version always show the same result for the same varchar, unlike MS SQL Server Management Studio







                                                                                            share|improve this answer














                                                                                            share|improve this answer



                                                                                            share|improve this answer








                                                                                            edited 2 days ago

























                                                                                            answered 2 days ago









                                                                                            t-clausen.dkt-clausen.dk

                                                                                            2,074314




                                                                                            2,074314





















                                                                                                0












                                                                                                $begingroup$


                                                                                                C# (Visual C# Interactive Compiler), 156 bytes





                                                                                                n=>var k=new Random();int i=0;foreach(var j in n.Skip(1).Zip(n,(a,b)=>a+b))for(Write(j[1]),i=0;i++<k.Next(5);)Write(k.Next()%2<1?j.ToUpper():j.ToLower());


                                                                                                Try it online!






                                                                                                share|improve this answer











                                                                                                $endgroup$

















                                                                                                  0












                                                                                                  $begingroup$


                                                                                                  C# (Visual C# Interactive Compiler), 156 bytes





                                                                                                  n=>var k=new Random();int i=0;foreach(var j in n.Skip(1).Zip(n,(a,b)=>a+b))for(Write(j[1]),i=0;i++<k.Next(5);)Write(k.Next()%2<1?j.ToUpper():j.ToLower());


                                                                                                  Try it online!






                                                                                                  share|improve this answer











                                                                                                  $endgroup$















                                                                                                    0












                                                                                                    0








                                                                                                    0





                                                                                                    $begingroup$


                                                                                                    C# (Visual C# Interactive Compiler), 156 bytes





                                                                                                    n=>var k=new Random();int i=0;foreach(var j in n.Skip(1).Zip(n,(a,b)=>a+b))for(Write(j[1]),i=0;i++<k.Next(5);)Write(k.Next()%2<1?j.ToUpper():j.ToLower());


                                                                                                    Try it online!






                                                                                                    share|improve this answer











                                                                                                    $endgroup$




                                                                                                    C# (Visual C# Interactive Compiler), 156 bytes





                                                                                                    n=>var k=new Random();int i=0;foreach(var j in n.Skip(1).Zip(n,(a,b)=>a+b))for(Write(j[1]),i=0;i++<k.Next(5);)Write(k.Next()%2<1?j.ToUpper():j.ToLower());


                                                                                                    Try it online!







                                                                                                    share|improve this answer














                                                                                                    share|improve this answer



                                                                                                    share|improve this answer








                                                                                                    edited 2 days ago

























                                                                                                    answered 2 days ago









                                                                                                    Embodiment of IgnoranceEmbodiment of Ignorance

                                                                                                    2,778127




                                                                                                    2,778127





















                                                                                                        0












                                                                                                        $begingroup$


                                                                                                        Japt -P, 43 16 bytes



                                                                                                        äÈ+(Zv +Zu)ö5ö Ä


                                                                                                        Shortened by a lot now!



                                                                                                        Try it






                                                                                                        share|improve this answer











                                                                                                        $endgroup$












                                                                                                        • $begingroup$
                                                                                                          This seems to return the same result every time.
                                                                                                          $endgroup$
                                                                                                          – Shaggy
                                                                                                          Apr 3 at 10:01










                                                                                                        • $begingroup$
                                                                                                          @Shaggy will fix. Also, ä's description says it gives three arguments, with the last being x+y. But as you can see here, it just returns 1. Is this a bug?
                                                                                                          $endgroup$
                                                                                                          – Embodiment of Ignorance
                                                                                                          2 days ago















                                                                                                        0












                                                                                                        $begingroup$


                                                                                                        Japt -P, 43 16 bytes



                                                                                                        äÈ+(Zv +Zu)ö5ö Ä


                                                                                                        Shortened by a lot now!



                                                                                                        Try it






                                                                                                        share|improve this answer











                                                                                                        $endgroup$












                                                                                                        • $begingroup$
                                                                                                          This seems to return the same result every time.
                                                                                                          $endgroup$
                                                                                                          – Shaggy
                                                                                                          Apr 3 at 10:01










                                                                                                        • $begingroup$
                                                                                                          @Shaggy will fix. Also, ä's description says it gives three arguments, with the last being x+y. But as you can see here, it just returns 1. Is this a bug?
                                                                                                          $endgroup$
                                                                                                          – Embodiment of Ignorance
                                                                                                          2 days ago













                                                                                                        0












                                                                                                        0








                                                                                                        0





                                                                                                        $begingroup$


                                                                                                        Japt -P, 43 16 bytes



                                                                                                        äÈ+(Zv +Zu)ö5ö Ä


                                                                                                        Shortened by a lot now!



                                                                                                        Try it






                                                                                                        share|improve this answer











                                                                                                        $endgroup$




                                                                                                        Japt -P, 43 16 bytes



                                                                                                        äÈ+(Zv +Zu)ö5ö Ä


                                                                                                        Shortened by a lot now!



                                                                                                        Try it







                                                                                                        share|improve this answer














                                                                                                        share|improve this answer



                                                                                                        share|improve this answer








                                                                                                        edited 2 days ago

























                                                                                                        answered Apr 3 at 5:18









                                                                                                        Embodiment of IgnoranceEmbodiment of Ignorance

                                                                                                        2,778127




                                                                                                        2,778127











                                                                                                        • $begingroup$
                                                                                                          This seems to return the same result every time.
                                                                                                          $endgroup$
                                                                                                          – Shaggy
                                                                                                          Apr 3 at 10:01










                                                                                                        • $begingroup$
                                                                                                          @Shaggy will fix. Also, ä's description says it gives three arguments, with the last being x+y. But as you can see here, it just returns 1. Is this a bug?
                                                                                                          $endgroup$
                                                                                                          – Embodiment of Ignorance
                                                                                                          2 days ago
















                                                                                                        • $begingroup$
                                                                                                          This seems to return the same result every time.
                                                                                                          $endgroup$
                                                                                                          – Shaggy
                                                                                                          Apr 3 at 10:01










                                                                                                        • $begingroup$
                                                                                                          @Shaggy will fix. Also, ä's description says it gives three arguments, with the last being x+y. But as you can see here, it just returns 1. Is this a bug?
                                                                                                          $endgroup$
                                                                                                          – Embodiment of Ignorance
                                                                                                          2 days ago















                                                                                                        $begingroup$
                                                                                                        This seems to return the same result every time.
                                                                                                        $endgroup$
                                                                                                        – Shaggy
                                                                                                        Apr 3 at 10:01




                                                                                                        $begingroup$
                                                                                                        This seems to return the same result every time.
                                                                                                        $endgroup$
                                                                                                        – Shaggy
                                                                                                        Apr 3 at 10:01












                                                                                                        $begingroup$
                                                                                                        @Shaggy will fix. Also, ä's description says it gives three arguments, with the last being x+y. But as you can see here, it just returns 1. Is this a bug?
                                                                                                        $endgroup$
                                                                                                        – Embodiment of Ignorance
                                                                                                        2 days ago




                                                                                                        $begingroup$
                                                                                                        @Shaggy will fix. Also, ä's description says it gives three arguments, with the last being x+y. But as you can see here, it just returns 1. Is this a bug?
                                                                                                        $endgroup$
                                                                                                        – Embodiment of Ignorance
                                                                                                        2 days ago











                                                                                                        0












                                                                                                        $begingroup$


                                                                                                        C (gcc), 110 bytes





                                                                                                        i,p;g(char*_)for(i=rand()%1024,putchar(*_);p=_[i%2],putchar(i&2&&p>64&~-p%32<26?p^32:p),i/=4;);_[2]&&g(_+1);


                                                                                                        Try it online!



                                                                                                        i,p;g(char*_)
                                                                                                        for(i=rand()%1024, //initialize: get 10 random bits
                                                                                                        putchar(*_); // and print current char
                                                                                                        p=_[i%2], //1st bit => current/next char
                                                                                                        putchar(i&2&& //2nd bit => toggle case
                                                                                                        p>64&~-p%32<26 // but only if char-to-print is alphabetic
                                                                                                        ?p^32:p),
                                                                                                        i/=4;); //discard two bits; run at least once
                                                                                                        _[2]&&g(_+1); //if not last char, repeat with next char




                                                                                                        The number of characters printed (per input character) is not uniformly random:



                                                                                                        1 if i< 4 ( 4/1024 = 1/256)
                                                                                                        2 if 4<=i< 16 ( 12/1024 = 3/256)
                                                                                                        3 if 16<=i< 64 ( 48/1024 = 3/ 64)
                                                                                                        4 if 64<=i< 256 (192/1024 = 3/ 16)
                                                                                                        5 if 256<=i<1023 (768/1024 = 3/ 4)





                                                                                                        share|improve this answer









                                                                                                        $endgroup$

















                                                                                                          0












                                                                                                          $begingroup$


                                                                                                          C (gcc), 110 bytes





                                                                                                          i,p;g(char*_)for(i=rand()%1024,putchar(*_);p=_[i%2],putchar(i&2&&p>64&~-p%32<26?p^32:p),i/=4;);_[2]&&g(_+1);


                                                                                                          Try it online!



                                                                                                          i,p;g(char*_)
                                                                                                          for(i=rand()%1024, //initialize: get 10 random bits
                                                                                                          putchar(*_); // and print current char
                                                                                                          p=_[i%2], //1st bit => current/next char
                                                                                                          putchar(i&2&& //2nd bit => toggle case
                                                                                                          p>64&~-p%32<26 // but only if char-to-print is alphabetic
                                                                                                          ?p^32:p),
                                                                                                          i/=4;); //discard two bits; run at least once
                                                                                                          _[2]&&g(_+1); //if not last char, repeat with next char




                                                                                                          The number of characters printed (per input character) is not uniformly random:



                                                                                                          1 if i< 4 ( 4/1024 = 1/256)
                                                                                                          2 if 4<=i< 16 ( 12/1024 = 3/256)
                                                                                                          3 if 16<=i< 64 ( 48/1024 = 3/ 64)
                                                                                                          4 if 64<=i< 256 (192/1024 = 3/ 16)
                                                                                                          5 if 256<=i<1023 (768/1024 = 3/ 4)





                                                                                                          share|improve this answer









                                                                                                          $endgroup$















                                                                                                            0












                                                                                                            0








                                                                                                            0





                                                                                                            $begingroup$


                                                                                                            C (gcc), 110 bytes





                                                                                                            i,p;g(char*_)for(i=rand()%1024,putchar(*_);p=_[i%2],putchar(i&2&&p>64&~-p%32<26?p^32:p),i/=4;);_[2]&&g(_+1);


                                                                                                            Try it online!



                                                                                                            i,p;g(char*_)
                                                                                                            for(i=rand()%1024, //initialize: get 10 random bits
                                                                                                            putchar(*_); // and print current char
                                                                                                            p=_[i%2], //1st bit => current/next char
                                                                                                            putchar(i&2&& //2nd bit => toggle case
                                                                                                            p>64&~-p%32<26 // but only if char-to-print is alphabetic
                                                                                                            ?p^32:p),
                                                                                                            i/=4;); //discard two bits; run at least once
                                                                                                            _[2]&&g(_+1); //if not last char, repeat with next char




                                                                                                            The number of characters printed (per input character) is not uniformly random:



                                                                                                            1 if i< 4 ( 4/1024 = 1/256)
                                                                                                            2 if 4<=i< 16 ( 12/1024 = 3/256)
                                                                                                            3 if 16<=i< 64 ( 48/1024 = 3/ 64)
                                                                                                            4 if 64<=i< 256 (192/1024 = 3/ 16)
                                                                                                            5 if 256<=i<1023 (768/1024 = 3/ 4)





                                                                                                            share|improve this answer









                                                                                                            $endgroup$




                                                                                                            C (gcc), 110 bytes





                                                                                                            i,p;g(char*_)for(i=rand()%1024,putchar(*_);p=_[i%2],putchar(i&2&&p>64&~-p%32<26?p^32:p),i/=4;);_[2]&&g(_+1);


                                                                                                            Try it online!



                                                                                                            i,p;g(char*_)
                                                                                                            for(i=rand()%1024, //initialize: get 10 random bits
                                                                                                            putchar(*_); // and print current char
                                                                                                            p=_[i%2], //1st bit => current/next char
                                                                                                            putchar(i&2&& //2nd bit => toggle case
                                                                                                            p>64&~-p%32<26 // but only if char-to-print is alphabetic
                                                                                                            ?p^32:p),
                                                                                                            i/=4;); //discard two bits; run at least once
                                                                                                            _[2]&&g(_+1); //if not last char, repeat with next char




                                                                                                            The number of characters printed (per input character) is not uniformly random:



                                                                                                            1 if i< 4 ( 4/1024 = 1/256)
                                                                                                            2 if 4<=i< 16 ( 12/1024 = 3/256)
                                                                                                            3 if 16<=i< 64 ( 48/1024 = 3/ 64)
                                                                                                            4 if 64<=i< 256 (192/1024 = 3/ 16)
                                                                                                            5 if 256<=i<1023 (768/1024 = 3/ 4)






                                                                                                            share|improve this answer












                                                                                                            share|improve this answer



                                                                                                            share|improve this answer










                                                                                                            answered 19 hours ago









                                                                                                            attinatattinat

                                                                                                            4797




                                                                                                            4797



























                                                                                                                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

                                                                                                                រឿង រ៉ូមេអូ និង ហ្ស៊ុយលីយេ សង្ខេបរឿង តួអង្គ បញ្ជីណែនាំ

                                                                                                                Crop image to path created in TikZ? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Crop an inserted image?TikZ pictures does not appear in posterImage behind and beyond crop marks?Tikz picture as large as possible on A4 PageTransparency vs image compression dilemmaHow to crop background from image automatically?Image does not cropTikzexternal capturing crop marks when externalizing pgfplots?How to include image path that contains a dollar signCrop image with left size given

                                                                                                                Romeo and Juliet ContentsCharactersSynopsisSourcesDate and textThemes and motifsCriticism and interpretationLegacyScene by sceneSee alsoNotes and referencesSourcesExternal linksNavigation menu"Consumer Price Index (estimate) 1800–"10.2307/28710160037-3222287101610.1093/res/II.5.31910.2307/45967845967810.2307/2869925286992510.1525/jams.1982.35.3.03a00050"Dada Masilo: South African dancer who breaks the rules"10.1093/res/os-XV.57.1610.2307/28680942868094"Sweet Sorrow: Mann-Korman's Romeo and Juliet Closes Sept. 5 at MN's Ordway"the original10.2307/45957745957710.1017/CCOL0521570476.009"Ram Leela box office collections hit massive Rs 100 crore, pulverises prediction"Archived"Broadway Revival of Romeo and Juliet, Starring Orlando Bloom and Condola Rashad, Will Close Dec. 8"Archived10.1075/jhp.7.1.04hon"Wherefore art thou, Romeo? To make us laugh at Navy Pier"the original10.1093/gmo/9781561592630.article.O006772"Ram-leela Review Roundup: Critics Hail Film as Best Adaptation of Romeo and Juliet"Archived10.2307/31946310047-77293194631"Romeo and Juliet get Twitter treatment""Juliet's Nurse by Lois Leveen""Romeo and Juliet: Orlando Bloom's Broadway Debut Released in Theaters for Valentine's Day"Archived"Romeo and Juliet Has No Balcony"10.1093/gmo/9781561592630.article.O00778110.2307/2867423286742310.1076/enst.82.2.115.959510.1080/00138380601042675"A plague o' both your houses: error in GCSE exam paper forces apology""Juliet of the Five O'Clock Shadow, and Other Wonders"10.2307/33912430027-4321339124310.2307/28487440038-7134284874410.2307/29123140149-661129123144728341M"Weekender Guide: Shakespeare on The Drive""balcony"UK public library membership"romeo"UK public library membership10.1017/CCOL9780521844291"Post-Zionist Critique on Israel and the Palestinians Part III: Popular Culture"10.2307/25379071533-86140377-919X2537907"Capulets and Montagues: UK exam board admit mixing names up in Romeo and Juliet paper"Istoria Novellamente Ritrovata di Due Nobili Amanti2027/mdp.390150822329610820-750X"GCSE exam error: Board accidentally rewrites Shakespeare"10.2307/29176390149-66112917639"Exam board apologises after error in English GCSE paper which confused characters in Shakespeare's Romeo and Juliet""From Mariotto and Ganozza to Romeo and Guilietta: Metamorphoses of a Renaissance Tale"10.2307/37323537323510.2307/2867455286745510.2307/28678912867891"10 Questions for Taylor Swift"10.2307/28680922868092"Haymarket Theatre""The Zeffirelli Way: Revealing Talk by Florentine Director""Michael Smuin: 1938-2007 / Prolific dance director had showy career"The Life and Art of Edwin BoothRomeo and JulietRomeo and JulietRomeo and JulietRomeo and JulietEasy Read Romeo and JulietRomeo and Julieteeecb12003684p(data)4099369-3n8211610759dbe00d-a9e2-41a3-b2c1-977dd692899302814385X313670221313670221