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

Should I cover my bicycle overnight while bikepacking?

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

Im going to France and my passport expires June 19th

Is "remove commented out code" correct English?

Could the museum Saturn V's be refitted for one more flight?

Are there any examples of a variable being normally distributed that is *not* due to the Central Limit Theorem?

Avoiding the "not like other girls" trope?

If human space travel is limited by the G force vulnerability, is there a way to counter G forces?

What mechanic is there to disable a threat instead of killing it?

Mathematica command that allows it to read my intentions

Should I tell management that I intend to leave due to bad software development practices?

Why no variance term in Bayesian logistic regression?

How to prevent "they're falling in love" trope

Solving a recurrence relation (poker chips)

When is a connective truth functional?

How do I handle a potential work/personal life conflict as the manager of one of my friends?

Plagiarism or not?

Unlock My Phone! February 2018

Determining Impedance With An Antenna Analyzer

Can my sorcerer use a spellbook only to collect spells and scribe scrolls, not cast?

Would Slavery Reparations be considered Bills of Attainder and hence Illegal?

Why can't we play rap on piano?

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

How seriously should I take size and weight limits of hand luggage?



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













15












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










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






  • 1




    $begingroup$
    I find the specification confusing. Can you be more explicit? For example, work out how String produces SSSTSStrTrIiinIIngn
    $endgroup$
    – Luis Mendo
    16 hours ago







  • 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
    14 hours ago







  • 2




    $begingroup$
    @KevinCruijssen Thanks, Your explanation fits the example, and is clear. The OP should confirm and edit that into the text
    $endgroup$
    – Luis Mendo
    14 hours ago
















15












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










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






  • 1




    $begingroup$
    I find the specification confusing. Can you be more explicit? For example, work out how String produces SSSTSStrTrIiinIIngn
    $endgroup$
    – Luis Mendo
    16 hours ago







  • 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
    14 hours ago







  • 2




    $begingroup$
    @KevinCruijssen Thanks, Your explanation fits the example, and is clear. The OP should confirm and edit that into the text
    $endgroup$
    – Luis Mendo
    14 hours ago














15












15








15


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







MilkyWay90

















asked yesterday









MilkyWay90MilkyWay90

675315




675315











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










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






  • 1




    $begingroup$
    I find the specification confusing. Can you be more explicit? For example, work out how String produces SSSTSStrTrIiinIIngn
    $endgroup$
    – Luis Mendo
    16 hours ago







  • 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
    14 hours ago







  • 2




    $begingroup$
    @KevinCruijssen Thanks, Your explanation fits the example, and is clear. The OP should confirm and edit that into the text
    $endgroup$
    – Luis Mendo
    14 hours ago

















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










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






  • 1




    $begingroup$
    I find the specification confusing. Can you be more explicit? For example, work out how String produces SSSTSStrTrIiinIIngn
    $endgroup$
    – Luis Mendo
    16 hours ago







  • 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
    14 hours ago







  • 2




    $begingroup$
    @KevinCruijssen Thanks, Your explanation fits the example, and is clear. The OP should confirm and edit that into the text
    $endgroup$
    – Luis Mendo
    14 hours ago
















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




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












$begingroup$
@ChasBrown Yeah, I'll edit the question
$endgroup$
– MilkyWay90
yesterday




$begingroup$
@ChasBrown Yeah, I'll edit the question
$endgroup$
– MilkyWay90
yesterday




1




1




$begingroup$
I find the specification confusing. Can you be more explicit? For example, work out how String produces SSSTSStrTrIiinIIngn
$endgroup$
– Luis Mendo
16 hours ago





$begingroup$
I find the specification confusing. Can you be more explicit? For example, work out how String produces SSSTSStrTrIiinIIngn
$endgroup$
– Luis Mendo
16 hours ago





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





$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
14 hours ago





2




2




$begingroup$
@KevinCruijssen Thanks, Your explanation fits the example, and is clear. The OP should confirm and edit that into the text
$endgroup$
– Luis Mendo
14 hours ago





$begingroup$
@KevinCruijssen Thanks, Your explanation fits the example, and is clear. The OP should confirm and edit that into the text
$endgroup$
– Luis Mendo
14 hours ago











17 Answers
17






active

oldest

votes


















5












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











  • $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
    15 hours ago







  • 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
    14 hours ago







  • 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
    14 hours ago


















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






  • 1




    $begingroup$
    do and done can be replaced with undocumented and
    $endgroup$
    – Nahuel Fouilleul
    17 hours ago










  • $begingroup$
    with some changes
    $endgroup$
    – Nahuel Fouilleul
    17 hours ago











  • $begingroup$
    @NahuelFouilleul tyvm. nice improvements and nice catch -- i'd somehow missed the requirement always to output the current char.
    $endgroup$
    – Jonah
    12 hours ago






  • 1




    $begingroup$
    @roblogic that's clever. tyvm.
    $endgroup$
    – Jonah
    4 hours ago


















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$


    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$




















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










      • $begingroup$
        @Shaggy Yes, I indeed can.. Thanks! Maybe I should stop golfing for today, I'm a mess, lol..
        $endgroup$
        – Kevin Cruijssen
        16 hours ago











      • $begingroup$
        You're a mess? ¨vNUy5LΩFy¹X>è«D.š«Ω?
        $endgroup$
        – Magic Octopus Urn
        13 hours ago






      • 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
        12 hours ago



















      2












      $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
        12 hours ago







      • 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
        9 hours ago



















      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$




















          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 bytes



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


                Try it online






                share|improve this answer









                $endgroup$












                • $begingroup$
                  I don't think you need the 0 in the first line.
                  $endgroup$
                  – LambdaBeta
                  4 hours ago










                • $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
                  4 hours ago


















                0












                $begingroup$


                Japt v2.0a0, 43 bytes



                s0UÊÉ)rÈ+Y+(C=[Yu Yv T=UgZÄ v Tu] cMq5 £C ö


                After a month of so of Japt, I'm still not very good at it.



                Try it






                share|improve this answer









                $endgroup$












                • $begingroup$
                  This seems to return the same result every time.
                  $endgroup$
                  – Shaggy
                  15 hours ago


















                0












                $begingroup$

                R, 179 bytes



                l=strsplit(s, "")[[1]];paste(unlist(sapply(1:nchar(w),function(i)sample(c(tolower(l[i:min(i+1,
                nchar(w))]),toupper(l[i:min(i+1,nchar(w))])),sample(5,1),replace=TRUE))),collapse="")





                share|improve this answer








                New contributor




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






                $endgroup$








                • 4




                  $begingroup$
                  welcome to PPCG! I believe you need to be able to take the string as an input, either as a function argument or from stdin. Feel free to ping me in the R golfer chat for help! I saw your username on the main page as having posted, and was not disappointed to find an R answer :-)
                  $endgroup$
                  – Giuseppe
                  14 hours ago










                • $begingroup$
                  You may also find these general golfing tips or these R golfing tips helpful as well.
                  $endgroup$
                  – Giuseppe
                  14 hours ago


















                0












                $begingroup$


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





                a=>int i=0;char b=a[0];var m=new Random();var s="";for(;i<a.Length;)for(dynamic j=m.Next(1,5),d=new []b,(char)(b^32),(b=a[i++]),(char)(b^32);j-->0;)s+=d[m.Next(0,3)];return s;


                Try it online!






                share|improve this answer









                $endgroup$




















                  0












                  $begingroup$


                  Jelly, 12 bytes



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


                  Try it online!






                  share|improve this answer









                  $endgroup$




















                    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$













                      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

























                      17 Answers
                      17






                      active

                      oldest

                      votes








                      17 Answers
                      17






                      active

                      oldest

                      votes









                      active

                      oldest

                      votes






                      active

                      oldest

                      votes









                      5












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











                      • $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
                        15 hours ago







                      • 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
                        14 hours ago







                      • 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
                        14 hours ago















                      5












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











                      • $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
                        15 hours ago







                      • 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
                        14 hours ago







                      • 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
                        14 hours ago













                      5












                      5








                      5





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

























                      answered yesterday









                      GiuseppeGiuseppe

                      17.4k31152




                      17.4k31152











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











                      • $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
                        15 hours ago







                      • 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
                        14 hours ago







                      • 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
                        14 hours ago
















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











                      • $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
                        15 hours ago







                      • 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
                        14 hours ago







                      • 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
                        14 hours ago















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





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













                      $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
                      15 hours ago





                      $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
                      15 hours ago





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





                      $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
                      14 hours ago





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




                      $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
                      14 hours ago











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






                      • 1




                        $begingroup$
                        do and done can be replaced with undocumented and
                        $endgroup$
                        – Nahuel Fouilleul
                        17 hours ago










                      • $begingroup$
                        with some changes
                        $endgroup$
                        – Nahuel Fouilleul
                        17 hours ago











                      • $begingroup$
                        @NahuelFouilleul tyvm. nice improvements and nice catch -- i'd somehow missed the requirement always to output the current char.
                        $endgroup$
                        – Jonah
                        12 hours ago






                      • 1




                        $begingroup$
                        @roblogic that's clever. tyvm.
                        $endgroup$
                        – Jonah
                        4 hours ago















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






                      • 1




                        $begingroup$
                        do and done can be replaced with undocumented and
                        $endgroup$
                        – Nahuel Fouilleul
                        17 hours ago










                      • $begingroup$
                        with some changes
                        $endgroup$
                        – Nahuel Fouilleul
                        17 hours ago











                      • $begingroup$
                        @NahuelFouilleul tyvm. nice improvements and nice catch -- i'd somehow missed the requirement always to output the current char.
                        $endgroup$
                        – Jonah
                        12 hours ago






                      • 1




                        $begingroup$
                        @roblogic that's clever. tyvm.
                        $endgroup$
                        – Jonah
                        4 hours ago













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

























                      answered 21 hours ago









                      JonahJonah

                      2,5011017




                      2,5011017











                      • $begingroup$
                        seems it's missing printf %s "$c"
                        $endgroup$
                        – Nahuel Fouilleul
                        17 hours ago






                      • 1




                        $begingroup$
                        do and done can be replaced with undocumented and
                        $endgroup$
                        – Nahuel Fouilleul
                        17 hours ago










                      • $begingroup$
                        with some changes
                        $endgroup$
                        – Nahuel Fouilleul
                        17 hours ago











                      • $begingroup$
                        @NahuelFouilleul tyvm. nice improvements and nice catch -- i'd somehow missed the requirement always to output the current char.
                        $endgroup$
                        – Jonah
                        12 hours ago






                      • 1




                        $begingroup$
                        @roblogic that's clever. tyvm.
                        $endgroup$
                        – Jonah
                        4 hours ago
















                      • $begingroup$
                        seems it's missing printf %s "$c"
                        $endgroup$
                        – Nahuel Fouilleul
                        17 hours ago






                      • 1




                        $begingroup$
                        do and done can be replaced with undocumented and
                        $endgroup$
                        – Nahuel Fouilleul
                        17 hours ago










                      • $begingroup$
                        with some changes
                        $endgroup$
                        – Nahuel Fouilleul
                        17 hours ago











                      • $begingroup$
                        @NahuelFouilleul tyvm. nice improvements and nice catch -- i'd somehow missed the requirement always to output the current char.
                        $endgroup$
                        – Jonah
                        12 hours ago






                      • 1




                        $begingroup$
                        @roblogic that's clever. tyvm.
                        $endgroup$
                        – Jonah
                        4 hours ago















                      $begingroup$
                      seems it's missing printf %s "$c"
                      $endgroup$
                      – Nahuel Fouilleul
                      17 hours ago




                      $begingroup$
                      seems it's missing printf %s "$c"
                      $endgroup$
                      – Nahuel Fouilleul
                      17 hours ago




                      1




                      1




                      $begingroup$
                      do and done can be replaced with undocumented and
                      $endgroup$
                      – Nahuel Fouilleul
                      17 hours ago




                      $begingroup$
                      do and done can be replaced with undocumented and
                      $endgroup$
                      – Nahuel Fouilleul
                      17 hours ago












                      $begingroup$
                      with some changes
                      $endgroup$
                      – Nahuel Fouilleul
                      17 hours ago





                      $begingroup$
                      with some changes
                      $endgroup$
                      – Nahuel Fouilleul
                      17 hours ago













                      $begingroup$
                      @NahuelFouilleul tyvm. nice improvements and nice catch -- i'd somehow missed the requirement always to output the current char.
                      $endgroup$
                      – Jonah
                      12 hours ago




                      $begingroup$
                      @NahuelFouilleul tyvm. nice improvements and nice catch -- i'd somehow missed the requirement always to output the current char.
                      $endgroup$
                      – Jonah
                      12 hours ago




                      1




                      1




                      $begingroup$
                      @roblogic that's clever. tyvm.
                      $endgroup$
                      – Jonah
                      4 hours ago




                      $begingroup$
                      @roblogic that's clever. tyvm.
                      $endgroup$
                      – Jonah
                      4 hours ago











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









                          Chas BrownChas Brown

                          5,1191523




                          5,1191523





















                              2












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

















                                2












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















                                  2












                                  2








                                  2





                                  $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 17 hours ago

























                                  answered yesterday









                                  AdámAdám

                                  28.9k276207




                                  28.9k276207





















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










                                      • $begingroup$
                                        @Shaggy Yes, I indeed can.. Thanks! Maybe I should stop golfing for today, I'm a mess, lol..
                                        $endgroup$
                                        – Kevin Cruijssen
                                        16 hours ago











                                      • $begingroup$
                                        You're a mess? ¨vNUy5LΩFy¹X>è«D.š«Ω?
                                        $endgroup$
                                        – Magic Octopus Urn
                                        13 hours ago






                                      • 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
                                        12 hours ago
















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










                                      • $begingroup$
                                        @Shaggy Yes, I indeed can.. Thanks! Maybe I should stop golfing for today, I'm a mess, lol..
                                        $endgroup$
                                        – Kevin Cruijssen
                                        16 hours ago











                                      • $begingroup$
                                        You're a mess? ¨vNUy5LΩFy¹X>è«D.š«Ω?
                                        $endgroup$
                                        – Magic Octopus Urn
                                        13 hours ago






                                      • 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
                                        12 hours ago














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

























                                      answered 17 hours ago









                                      Kevin CruijssenKevin Cruijssen

                                      42.2k570217




                                      42.2k570217











                                      • $begingroup$
                                        I don't know 05AB1E but, instead of INè, could you save anything by pushing the first character of y?
                                        $endgroup$
                                        – Shaggy
                                        16 hours ago










                                      • $begingroup$
                                        @Shaggy Yes, I indeed can.. Thanks! Maybe I should stop golfing for today, I'm a mess, lol..
                                        $endgroup$
                                        – Kevin Cruijssen
                                        16 hours ago











                                      • $begingroup$
                                        You're a mess? ¨vNUy5LΩFy¹X>è«D.š«Ω?
                                        $endgroup$
                                        – Magic Octopus Urn
                                        13 hours ago






                                      • 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
                                        12 hours ago

















                                      • $begingroup$
                                        I don't know 05AB1E but, instead of INè, could you save anything by pushing the first character of y?
                                        $endgroup$
                                        – Shaggy
                                        16 hours ago










                                      • $begingroup$
                                        @Shaggy Yes, I indeed can.. Thanks! Maybe I should stop golfing for today, I'm a mess, lol..
                                        $endgroup$
                                        – Kevin Cruijssen
                                        16 hours ago











                                      • $begingroup$
                                        You're a mess? ¨vNUy5LΩFy¹X>è«D.š«Ω?
                                        $endgroup$
                                        – Magic Octopus Urn
                                        13 hours ago






                                      • 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
                                        12 hours ago
















                                      $begingroup$
                                      I don't know 05AB1E but, instead of INè, could you save anything by pushing the first character of y?
                                      $endgroup$
                                      – Shaggy
                                      16 hours ago




                                      $begingroup$
                                      I don't know 05AB1E but, instead of INè, could you save anything by pushing the first character of y?
                                      $endgroup$
                                      – Shaggy
                                      16 hours ago












                                      $begingroup$
                                      @Shaggy Yes, I indeed can.. Thanks! Maybe I should stop golfing for today, I'm a mess, lol..
                                      $endgroup$
                                      – Kevin Cruijssen
                                      16 hours ago





                                      $begingroup$
                                      @Shaggy Yes, I indeed can.. Thanks! Maybe I should stop golfing for today, I'm a mess, lol..
                                      $endgroup$
                                      – Kevin Cruijssen
                                      16 hours ago













                                      $begingroup$
                                      You're a mess? ¨vNUy5LΩFy¹X>è«D.š«Ω?
                                      $endgroup$
                                      – Magic Octopus Urn
                                      13 hours ago




                                      $begingroup$
                                      You're a mess? ¨vNUy5LΩFy¹X>è«D.š«Ω?
                                      $endgroup$
                                      – Magic Octopus Urn
                                      13 hours ago




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





                                      $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
                                      12 hours ago












                                      2












                                      $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
                                        12 hours ago







                                      • 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
                                        9 hours ago
















                                      2












                                      $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
                                        12 hours ago







                                      • 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
                                        9 hours ago














                                      2












                                      2








                                      2





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









                                      Jo KingJo King

                                      26.4k364130




                                      26.4k364130











                                      • $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
                                        12 hours ago







                                      • 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
                                        9 hours 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
                                        12 hours ago







                                      • 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
                                        9 hours 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
                                      12 hours 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
                                      12 hours ago





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





                                      $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
                                      9 hours ago












                                      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 yesterday









                                          NeilNeil

                                          82.4k745179




                                          82.4k745179





















                                              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$

















                                                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$















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









                                                  Nahuel FouilleulNahuel Fouilleul

                                                  3,005211




                                                  3,005211





















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

























                                                          answered 15 hours ago









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









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

























                                                                          answered 19 hours ago









                                                                          Nick KennedyNick Kennedy

                                                                          1,29649




                                                                          1,29649





















                                                                              1












                                                                              $begingroup$

                                                                              C(GCC) 175 bytes



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


                                                                              Try it online






                                                                              share|improve this answer









                                                                              $endgroup$












                                                                              • $begingroup$
                                                                                I don't think you need the 0 in the first line.
                                                                                $endgroup$
                                                                                – LambdaBeta
                                                                                4 hours ago










                                                                              • $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
                                                                                4 hours ago















                                                                              1












                                                                              $begingroup$

                                                                              C(GCC) 175 bytes



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


                                                                              Try it online






                                                                              share|improve this answer









                                                                              $endgroup$












                                                                              • $begingroup$
                                                                                I don't think you need the 0 in the first line.
                                                                                $endgroup$
                                                                                – LambdaBeta
                                                                                4 hours ago










                                                                              • $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
                                                                                4 hours ago













                                                                              1












                                                                              1








                                                                              1





                                                                              $begingroup$

                                                                              C(GCC) 175 bytes



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


                                                                              Try it online






                                                                              share|improve this answer









                                                                              $endgroup$



                                                                              C(GCC) 175 bytes



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


                                                                              Try it online







                                                                              share|improve this answer












                                                                              share|improve this answer



                                                                              share|improve this answer










                                                                              answered 7 hours ago









                                                                              rtpaxrtpax

                                                                              3165




                                                                              3165











                                                                              • $begingroup$
                                                                                I don't think you need the 0 in the first line.
                                                                                $endgroup$
                                                                                – LambdaBeta
                                                                                4 hours ago










                                                                              • $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
                                                                                4 hours ago
















                                                                              • $begingroup$
                                                                                I don't think you need the 0 in the first line.
                                                                                $endgroup$
                                                                                – LambdaBeta
                                                                                4 hours ago










                                                                              • $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
                                                                                4 hours ago















                                                                              $begingroup$
                                                                              I don't think you need the 0 in the first line.
                                                                              $endgroup$
                                                                              – LambdaBeta
                                                                              4 hours ago




                                                                              $begingroup$
                                                                              I don't think you need the 0 in the first line.
                                                                              $endgroup$
                                                                              – LambdaBeta
                                                                              4 hours ago












                                                                              $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
                                                                              4 hours ago




                                                                              $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
                                                                              4 hours ago











                                                                              0












                                                                              $begingroup$


                                                                              Japt v2.0a0, 43 bytes



                                                                              s0UÊÉ)rÈ+Y+(C=[Yu Yv T=UgZÄ v Tu] cMq5 £C ö


                                                                              After a month of so of Japt, I'm still not very good at it.



                                                                              Try it






                                                                              share|improve this answer









                                                                              $endgroup$












                                                                              • $begingroup$
                                                                                This seems to return the same result every time.
                                                                                $endgroup$
                                                                                – Shaggy
                                                                                15 hours ago















                                                                              0












                                                                              $begingroup$


                                                                              Japt v2.0a0, 43 bytes



                                                                              s0UÊÉ)rÈ+Y+(C=[Yu Yv T=UgZÄ v Tu] cMq5 £C ö


                                                                              After a month of so of Japt, I'm still not very good at it.



                                                                              Try it






                                                                              share|improve this answer









                                                                              $endgroup$












                                                                              • $begingroup$
                                                                                This seems to return the same result every time.
                                                                                $endgroup$
                                                                                – Shaggy
                                                                                15 hours ago













                                                                              0












                                                                              0








                                                                              0





                                                                              $begingroup$


                                                                              Japt v2.0a0, 43 bytes



                                                                              s0UÊÉ)rÈ+Y+(C=[Yu Yv T=UgZÄ v Tu] cMq5 £C ö


                                                                              After a month of so of Japt, I'm still not very good at it.



                                                                              Try it






                                                                              share|improve this answer









                                                                              $endgroup$




                                                                              Japt v2.0a0, 43 bytes



                                                                              s0UÊÉ)rÈ+Y+(C=[Yu Yv T=UgZÄ v Tu] cMq5 £C ö


                                                                              After a month of so of Japt, I'm still not very good at it.



                                                                              Try it







                                                                              share|improve this answer












                                                                              share|improve this answer



                                                                              share|improve this answer










                                                                              answered 20 hours ago









                                                                              Embodiment of IgnoranceEmbodiment of Ignorance

                                                                              2,358126




                                                                              2,358126











                                                                              • $begingroup$
                                                                                This seems to return the same result every time.
                                                                                $endgroup$
                                                                                – Shaggy
                                                                                15 hours ago
















                                                                              • $begingroup$
                                                                                This seems to return the same result every time.
                                                                                $endgroup$
                                                                                – Shaggy
                                                                                15 hours ago















                                                                              $begingroup$
                                                                              This seems to return the same result every time.
                                                                              $endgroup$
                                                                              – Shaggy
                                                                              15 hours ago




                                                                              $begingroup$
                                                                              This seems to return the same result every time.
                                                                              $endgroup$
                                                                              – Shaggy
                                                                              15 hours ago











                                                                              0












                                                                              $begingroup$

                                                                              R, 179 bytes



                                                                              l=strsplit(s, "")[[1]];paste(unlist(sapply(1:nchar(w),function(i)sample(c(tolower(l[i:min(i+1,
                                                                              nchar(w))]),toupper(l[i:min(i+1,nchar(w))])),sample(5,1),replace=TRUE))),collapse="")





                                                                              share|improve this answer








                                                                              New contributor




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






                                                                              $endgroup$








                                                                              • 4




                                                                                $begingroup$
                                                                                welcome to PPCG! I believe you need to be able to take the string as an input, either as a function argument or from stdin. Feel free to ping me in the R golfer chat for help! I saw your username on the main page as having posted, and was not disappointed to find an R answer :-)
                                                                                $endgroup$
                                                                                – Giuseppe
                                                                                14 hours ago










                                                                              • $begingroup$
                                                                                You may also find these general golfing tips or these R golfing tips helpful as well.
                                                                                $endgroup$
                                                                                – Giuseppe
                                                                                14 hours ago















                                                                              0












                                                                              $begingroup$

                                                                              R, 179 bytes



                                                                              l=strsplit(s, "")[[1]];paste(unlist(sapply(1:nchar(w),function(i)sample(c(tolower(l[i:min(i+1,
                                                                              nchar(w))]),toupper(l[i:min(i+1,nchar(w))])),sample(5,1),replace=TRUE))),collapse="")





                                                                              share|improve this answer








                                                                              New contributor




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






                                                                              $endgroup$








                                                                              • 4




                                                                                $begingroup$
                                                                                welcome to PPCG! I believe you need to be able to take the string as an input, either as a function argument or from stdin. Feel free to ping me in the R golfer chat for help! I saw your username on the main page as having posted, and was not disappointed to find an R answer :-)
                                                                                $endgroup$
                                                                                – Giuseppe
                                                                                14 hours ago










                                                                              • $begingroup$
                                                                                You may also find these general golfing tips or these R golfing tips helpful as well.
                                                                                $endgroup$
                                                                                – Giuseppe
                                                                                14 hours ago













                                                                              0












                                                                              0








                                                                              0





                                                                              $begingroup$

                                                                              R, 179 bytes



                                                                              l=strsplit(s, "")[[1]];paste(unlist(sapply(1:nchar(w),function(i)sample(c(tolower(l[i:min(i+1,
                                                                              nchar(w))]),toupper(l[i:min(i+1,nchar(w))])),sample(5,1),replace=TRUE))),collapse="")





                                                                              share|improve this answer








                                                                              New contributor




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






                                                                              $endgroup$



                                                                              R, 179 bytes



                                                                              l=strsplit(s, "")[[1]];paste(unlist(sapply(1:nchar(w),function(i)sample(c(tolower(l[i:min(i+1,
                                                                              nchar(w))]),toupper(l[i:min(i+1,nchar(w))])),sample(5,1),replace=TRUE))),collapse="")






                                                                              share|improve this answer








                                                                              New contributor




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









                                                                              share|improve this answer



                                                                              share|improve this answer






                                                                              New contributor




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









                                                                              answered 14 hours ago









                                                                              BigDataScientistBigDataScientist

                                                                              1011




                                                                              1011




                                                                              New contributor




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





                                                                              New contributor





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






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







                                                                              • 4




                                                                                $begingroup$
                                                                                welcome to PPCG! I believe you need to be able to take the string as an input, either as a function argument or from stdin. Feel free to ping me in the R golfer chat for help! I saw your username on the main page as having posted, and was not disappointed to find an R answer :-)
                                                                                $endgroup$
                                                                                – Giuseppe
                                                                                14 hours ago










                                                                              • $begingroup$
                                                                                You may also find these general golfing tips or these R golfing tips helpful as well.
                                                                                $endgroup$
                                                                                – Giuseppe
                                                                                14 hours ago












                                                                              • 4




                                                                                $begingroup$
                                                                                welcome to PPCG! I believe you need to be able to take the string as an input, either as a function argument or from stdin. Feel free to ping me in the R golfer chat for help! I saw your username on the main page as having posted, and was not disappointed to find an R answer :-)
                                                                                $endgroup$
                                                                                – Giuseppe
                                                                                14 hours ago










                                                                              • $begingroup$
                                                                                You may also find these general golfing tips or these R golfing tips helpful as well.
                                                                                $endgroup$
                                                                                – Giuseppe
                                                                                14 hours ago







                                                                              4




                                                                              4




                                                                              $begingroup$
                                                                              welcome to PPCG! I believe you need to be able to take the string as an input, either as a function argument or from stdin. Feel free to ping me in the R golfer chat for help! I saw your username on the main page as having posted, and was not disappointed to find an R answer :-)
                                                                              $endgroup$
                                                                              – Giuseppe
                                                                              14 hours ago




                                                                              $begingroup$
                                                                              welcome to PPCG! I believe you need to be able to take the string as an input, either as a function argument or from stdin. Feel free to ping me in the R golfer chat for help! I saw your username on the main page as having posted, and was not disappointed to find an R answer :-)
                                                                              $endgroup$
                                                                              – Giuseppe
                                                                              14 hours ago












                                                                              $begingroup$
                                                                              You may also find these general golfing tips or these R golfing tips helpful as well.
                                                                              $endgroup$
                                                                              – Giuseppe
                                                                              14 hours ago




                                                                              $begingroup$
                                                                              You may also find these general golfing tips or these R golfing tips helpful as well.
                                                                              $endgroup$
                                                                              – Giuseppe
                                                                              14 hours ago











                                                                              0












                                                                              $begingroup$


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





                                                                              a=>int i=0;char b=a[0];var m=new Random();var s="";for(;i<a.Length;)for(dynamic j=m.Next(1,5),d=new []b,(char)(b^32),(b=a[i++]),(char)(b^32);j-->0;)s+=d[m.Next(0,3)];return s;


                                                                              Try it online!






                                                                              share|improve this answer









                                                                              $endgroup$

















                                                                                0












                                                                                $begingroup$


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





                                                                                a=>int i=0;char b=a[0];var m=new Random();var s="";for(;i<a.Length;)for(dynamic j=m.Next(1,5),d=new []b,(char)(b^32),(b=a[i++]),(char)(b^32);j-->0;)s+=d[m.Next(0,3)];return s;


                                                                                Try it online!






                                                                                share|improve this answer









                                                                                $endgroup$















                                                                                  0












                                                                                  0








                                                                                  0





                                                                                  $begingroup$


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





                                                                                  a=>int i=0;char b=a[0];var m=new Random();var s="";for(;i<a.Length;)for(dynamic j=m.Next(1,5),d=new []b,(char)(b^32),(b=a[i++]),(char)(b^32);j-->0;)s+=d[m.Next(0,3)];return s;


                                                                                  Try it online!






                                                                                  share|improve this answer









                                                                                  $endgroup$




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





                                                                                  a=>int i=0;char b=a[0];var m=new Random();var s="";for(;i<a.Length;)for(dynamic j=m.Next(1,5),d=new []b,(char)(b^32),(b=a[i++]),(char)(b^32);j-->0;)s+=d[m.Next(0,3)];return s;


                                                                                  Try it online!







                                                                                  share|improve this answer












                                                                                  share|improve this answer



                                                                                  share|improve this answer










                                                                                  answered 9 hours ago









                                                                                  Expired DataExpired Data

                                                                                  51813




                                                                                  51813





















                                                                                      0












                                                                                      $begingroup$


                                                                                      Jelly, 12 bytes



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


                                                                                      Try it online!






                                                                                      share|improve this answer









                                                                                      $endgroup$

















                                                                                        0












                                                                                        $begingroup$


                                                                                        Jelly, 12 bytes



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


                                                                                        Try it online!






                                                                                        share|improve this answer









                                                                                        $endgroup$















                                                                                          0












                                                                                          0








                                                                                          0





                                                                                          $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 8 hours ago









                                                                                          Erik the OutgolferErik the Outgolfer

                                                                                          32.9k429106




                                                                                          32.9k429106





















                                                                                              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$

















                                                                                                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$















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









                                                                                                  SorenSoren

                                                                                                  2008




                                                                                                  2008



























                                                                                                      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

                                                                                                      Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                                                                                                      Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                                                                                                      Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form