[Question]
  [
Given string `s` of even length as input, randomly capitalize exactly half of the letters.
* You can assume the input will always be a non-zero, even length
* You can assume the input will consist of only lowercase letters (`[a-z]`)
* Exactly half of the letters should be capitalized in the output
* Every permutation that has exactly half of the characters capitalized should have an equal probability of being output
## Scoring
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so fewest bytes **in each language** wins!
  
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 7 bytes
### Code
Uses the [05AB1E codepage](https://github.com/Adriandmen/05AB1E/blob/master/docs/code-page.md).
```
ā.rÈÅÏu
```
[Try it online!](https://tio.run/##yy9OTMpM/f//SKNe0eGOw62H@0v//09MSk5JTUvPAAA "05AB1E – Try It Online")
### Explanation
```
             # *example input: "**abcdefgh**"*
ā            # Indices of the input                   -> ex. [1, 2, 3, 4, 5, 6, 7, 8]
 .r          # Randomly shuffle this list             -> ex. [5, 4, 6, 3, 2, 8, 1, 7]
   È         # Map (x % 2 == 0) on each element       -> ex. [0, 1, 1, 0, 1, 1, 0, 0]
    ÅÏ       # Apply the following on truthy indices:
      u      #   Convert to uppercase                 -> ex. "aBCdEFgh"
```
[Answer]
# [R](https://www.r-project.org/), ~~52~~ ~~51~~ 33 bytes
Or **[R](https://www.r-project.org/)>=4.1, 25 bytes** by replacing the word `function` with `\`.
```
function(s)s-sample(seq(s))%%2*32
```
[Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP0@jWLNYtzgxtyAnVaM4tRDI1VRVNdIyNvqfmVcSkh9akmahkaZRCqRC8j3zSjSUEpOUNDU1uciUTU5JTUvPAKv5DwA "R – Try It Online")
Inputs and outputs through vector of character codes.
Inspired by [@Adnan's solution](https://codegolf.stackexchange.com/a/237903/55372).
[Answer]
# [C (clang)](http://clang.llvm.org/), ~~57~~ 56 bytes
```
i,r;f(*s,z){for(i=z;s[r=rand()%z]>96?s[r]-=32,i-=2:i;);}
```
[Try it online!](https://tio.run/##HcrRCsIgFADQ931FCINrKKwFQYn1A/3B2INsWhechgqBY99urtfDmfhklXuVgiwIA8fIMl2ND4AyizgEGZSbgbZ5vF8vjwojl@eeIZf9DQUVW1kUOqBrE/8z4aKho1Q06NIh6ZiGUT7JW1vrvz7YmYjGwO7s1NX1CfUZIK2NhO1cbSs/ "C (clang) – Try It Online")
* takes a pointer to a widechar string and modifies it.
[Answer]
# [Python](https://www.python.org), 86 bytes
```
lambda s:bytes(map(int.__xor__,s,sample(len(s)//2*[0,32],len(s))))
from random import*
```
[Attempt This Online!](https://ato.pxeger.com/run?1=LYxLCsIwFEXnrqLg5KXEVOpEhG7DiUpImhcsNB-SFOxanBTE7sndGEjv5H64nPfq5_R0dvno7v6dkj6cf9dRGKlEFS9yThjBCA-DTYzzlwuc00ijMH5EGNFCJE3T1rcjPbUPWoasnQ7OVEFYlW0w3oVUb_S9DxkGOiP9lIAwtL1TCIQwhVsq12UVsleoS_sD)
Uses [Rɪᴋᴇʀ's idea](https://chat.stackexchange.com/transcript/message/59760574) to toggle case using `^32`, but taken a bit further.
-1 byte thanks to @ovs.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jellylanguage), 8 bytes
```
ŒuJḂẊTƲ¦
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m700KzUnp3LBgqWlJWm6FuuPTir1erij6eGurpBjmw4tW1KclFwMlVsVrZSYlJySmqYUCxUBAA)
Using the mod-2 trick from [Adnan's 05AB1E answer](https://codegolf.stackexchange.com/a/237903/97857).
Explanation:
```
ŒuJḂẊTƲ¦
Œu   TƲ¦   uppercase at truthy indices:
  J          range [1..length(input()]
   Ḃ         each modulo 2
    Ẋ        random permutation
```
`JḂ` essentially creates `[0, 1, 0, 1, ..., 0, 1]` up to the length of the input.
# [Jelly](https://github.com/DennisMitchell/jellylanguage), 9 bytes
```
ŒuJẊŒHḢƲ¦
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m700KzUnp3LBgqWlJWm6FhuPTir1erir6-gkj4c7Fh3bdGjZkuKk5GKo7KpopcSk5JTUNKVYqAgA)
Explanation:
```
ŒuJẊŒHḢƲ¦
Œu     Ʋ¦   uppercase at indices:
  JẊ          random permutation of [1..length(input)]
    ŒH        split that list into two halves
      Ḣ       take the first of those two halves
```
I think there ought to be a shorter way of doing the `JẊŒHḢ`, ~~perhaps by picking a random combination~~[nope](https://ato.pxeger.com/run?1=m700KzUnp3LBgqWlJWm6FuuPTir1Ojo52cdDJeLYpkPLlhQnJRdD5VZFKyUmJaekpinFQkUA). Or, at least, a shorter version of `ŒHḢ`.
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), ~~14~~ 9 bytes
−5 bytes thanks to ovs.
Anonymous tacit prefix function
```
⌈@(2|≢?≢)
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn//1FPh4OGUc2jzkX2QKz5P@1R24RHvX2Pupof9a551Lvl0HrjR20TH/VNDQ5yBpIhHp7B/9PUM1JzcvLL84tyUtQB "APL (Dyalog Extended) – Try It Online")
`⌈` uppercase
`@(`…`)` at the positions indicated by the following mask:
 `≢?≢` shuffle the indices 1 through the tally of elements in the argument (lit. take n random elements from 1…n, without replacement)
 `2|` division remainders when divided by 2
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 76 bytes
```
f=s=>(S=Buffer(s).map(c=>c^=Math.random(n++)<.5?32:--n-n--,n=0),n?f(s):S)+''
```
[Try it online!](https://tio.run/##DcvBCoMwDADQf/FiQm0ZG7vIorD7Tt4HpbabQxNp1N/v5J3fzx9eQ57WzbKMsZRESh0M9NxTihkU3eJXCNSFN7389nXZ8ygLsDH4cPf@dm2t5ZNtmC7YcJ/O1A5o6roEYZU5ulk@kKDaeTpi1lghlj8 "JavaScript (Node.js) – Try It Online")
### Commented
```
f = s =>               // s = input string
( S =                  // S = output
  Buffer(s)            // turn s into a buffer
  .map(c =>            // for each ASCII code c in s:
    c ^=               //   update c:
      Math.random(n++) //     increment n
      < .5 ?           //     with 1/2 probability:
        32             //       turn c into uppercase
      :                //     or:
        --n - n--,     //       leave c unchanged and decrement n twice
    n = 0              //   start with n = 0
  ),                   // end of map()
  n ? f(s)             // try again if we haven't capitalized exactly
                       // half of the letters
    : S                // otherwise, stop and return S
)                      //
+ ''                   // coerce the output buffer back to a string
```
[Answer]
# [J](http://jsoftware.com/), 21 bytes
```
toupper@{~`]`[}-:@#?#
```
[Try it online!](https://tio.run/##y/pvqWhlGGumaGWprs6lpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/S/JLCwpSixyq6xJiE6Jrda0clO2V/2typSZn5CukKagnJiWnpKalZ6iTJ/IfAA "J – Try It Online")
* `-:@#?#` Randomly "Deal" `?` half-the-length `-:@#` number of indices from all possible indices.
* `toupper@{~`]`[}` And Amend `}` just those indices with their uppercased versions `toupper@{~`.
[Answer]
# JavaScript (ES6), 154 bytes
*-1 thanks to emanresu A, with their `v<{}` trick*
```
s=>(t=(f=x=>x?f(x.slice(1)).flatMap(y=>[x[0]+y,x[0].toUpperCase()+y]):[""])(s).filter(w=>![...w].reduce((u,v)=>u+(v<{})*2-1,0)))[Math.random()*t.length|0]
```
**Explanation:**
* `(f=x=>x?f(x.slice(1)).flatMap(y=>[x[0]+y,x[0].toUpperCase()+y]):[""])(s)`: Recursively finds all ways to capitalize the string
* `.filter(w=>![...w].reduce((u,v)=>u+(v<{})*2-1,0))`: Filters out items which don't have the correct number of capitalized letters, by checking if the sum of `-1` (for capitalized) and `1` (for lowercase) is `0`
* `[Math.random()*t.length|0]`: Choose a random item
[Answer]
# [Jelly](https://github.com/DennisMitchell/jellylanguage), 8 bytes
```
JẊị"żŒu$
```
[Try It Online!](https://jht.hyper-neutrino.xyz/tio#WyIiLCJK4bqK4buLXCLFvMWSdSQiLCIiLCIiLFsiaGVsbG93b3JsZCJdXQ==)
-2 bytes thanks to a clever trick from Adnan using cyclical indexing, thus tying pxeger's answer
```
JẊị"żŒu$    Main Link
J           [1, 2, ..., len(input)]
 Ẋ          random permutation of that
  ị"        vectorize - index (half of them are even, half are odd, and it wraps)
    żŒu$    the input zipped with itself capitalized
```
[Answer]
# [Factor](https://factorcode.org/) + `sequences.repeating`, ~~43~~ 39 bytes
```
[ "\0 "over length cycle randomize v- ]
```
[Try it online!](https://tio.run/##Rcw7CgIxFAXQflZxSe9grQsQGxuxUosYr0kwn5mXTEA3HxEE@8N5aFOz9NNxf9ht8KQkBhTOC5Nhgeh0zxFRVzc2fmmBz38wCifq6pPFdhiU0/G2iKUU1c9QlzVUbhQEJlsdzMsE/k7/JtoK1250CJjEp9o/ "Factor – Try It Online")
```
            ! "hamburgers"
"\0 "       ! "hamburgers" "\0 "
over        ! "hamburgers" "\0 " "hamburgers"
length      ! "hamburgers" "\0 " 10
cycle       ! "hamburgers" "\0 \0 \0 \0 \0 "
randomize   ! "hamburgers" "\0\0\0    \0 \0"
v-          ! "hamBURGeRs"
```
[Answer]
# [C (clang)](http://clang.llvm.org/), ~~58~~ 51 bytes
-1 thanks to [AZTECCO](https://codegolf.stackexchange.com/questions/237895/randomly-capitalize-half-of-a-string/237931?noredirect=1#comment539485_237931)  
-6 with wide string and clang
```
i;f(*s,l){for(i=l/2;rand()%l--<i?s[l]^=32,--i:i;);}
```
[Try it online!](https://tio.run/##TY1LjsIwEETX@BTGEsgmtiYEVjgWF@AGmYwUmQS15HSQnfmIiLOHJqtZdavqVZU3PjR4m2ewndwlHdTUDVGCCx@FjQ1epdoEY0o4pyrUX@5QaGPgBFbZ59w3gFJNDHDkgFXNHb@IxrfQ4xDT98/v30PYxQ0tcnL3R8tYWmpH6FuZK2VZJwH1m6D/HonupNiE9IlCw1tbCvxI8ZzgIXK57LnccigpRifLFFsRkjm@JreCenso/tddhfYjCc/5BQ "C (clang) – Try It Online")
Outputs by modifying the input string.
Each letter has a \$\frac in\$ chance of being capitalized, where \$i\$ is the number of remaining capital letters and \$n\$ is the number of remaining letters (including this one).
[Answer]
# [Julia 1.0](http://julialang.org/), 73 bytes
```
!s=(E=length(s);v=rand(E);prod(i->s[i]-32*(i∈sortperm(v)[1:E÷2]),1:E))
```
[Try it online!](https://tio.run/##RY5BDoIwFET3nKKw@t8AQnUlqTtOQdA0UrUGCukvxCNwIw/gTbwIQkh09SaZvMw8@lrL9DlNPgnIRa3Mzd2BMBuElaaCHLPOthXo6EiFLqMd34D@jCO11nXKNjBgkR7y94uXGM4BcXKK3PkiSRETrAhkcOIhW7BfkSYreVJ63rW1jJg27G95ndXG1Qaob0BT3807SxFD4VMcxyUiE4L9rm45espU0xc "Julia 1.0 – Try It Online")
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 81 bytes
```
/^((?<-2>[a-z])|(?<-3>[A-Z])|([A-Z])|([a-z]))*(?(2)^)(?(3)^)$/^+/./_?(T`l`L
T`L`l
```
[Try it online!](https://tio.run/##K0otycxLNPyvquGe8F8/TkPD3kbXyC46UbcqVrMGxDG2i3bUjQJx4DRYUlNLw17DSDNOE0gZAykV/ThtfT39eHuNkIScBB@ukASfhJz//5MTCzJLEnMyi1O5ihLzUvJzcyoB "Retina – Try It Online") Explanation:
```
/^((?<-2>[a-z])|(?<-3>[A-Z])|([A-Z])|([a-z]))*(?(2)^)(?(3)^)$/
```
Check whether the input contains equal numbers of lower and upper case letters. Groups `2` and `3` contain any excess upper and lower case letters respectively; if they are non-empty then the letter of the opposite case decrements the group, otherwise the letter increments the group appropriately. At the end both groups are required to be empty.
```
^+
```
Repeat while it does not.
```
/./_
```
Loop over each letter.
```
?(
```
Random choice between one of the following.
```
T`l`L
```
Uppercase.
```
T`L`l
```
Lowercase.
[Answer]
# [Perl 5](https://www.perl.org/) `-F`, 49 bytes
```
@k{0..$#F}=1;map$_=uc,@F[(keys%k)[1..@F/2]];say@F
```
[Try it online!](https://tio.run/##K0gtyjH9/98hu9pAT09F2a3W1tA6N7FAJd62NFnHwS1aIzu1slg1WzPaUE/PwU3fKDbWujix0sHt///EpOSUf/kFJZn5ecX/dX1N9QwMDf7rugEA "Perl 5 – Try It Online")
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 52 bytes
```
MapAt[Capitalize,#,RandomSample[i=0;{++i}&/@#,i/2]]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2773zexwLEk2jmxILMkMSezKlVHWScoMS8lPzc4MbcgJzU609bAulpbO7NWTd9BWSdT3yg2Vu1/QFFmXomDVnAJkE73ys/MU3BId3DOSCxKTC5JLSqOVioCG1EMlleK/f8fAA "Wolfram Language (Mathematica) – Try It Online")
-16 bytes thanks to @att
[Answer]
# [Ruby](https://www.ruby-lang.org/), 59 bytes
```
->s{[*0...q=s.size].sample(q/2).map{|w|s[w]=s[w].upcase};s}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1664OlrLQE9Pr9C2WK84syo1Vq84MbcgJ1WjUN9IUy83saC6prymOLo81hZE6JUWJCcWp9ZaF9f@L1BIi1YqSS0uUYr9DwA "Ruby – Try It Online")
[Answer]
# [C#](https://docs.microsoft.com/en-us/dotnet/csharp/%3E!), 145 bytes
Hey! I'm completely new to this and my answer will make that apparent. I thought I'd post so that I can refer back to later to see my progress. Let me know if I anything is incorrect involving my answer.
didn't include logging, output is the t string
```
string t="";int p=0;while(p!=s.Length/2){t="";p=0;foreach(char c in s){char l=c;if(new Random().Next(2)==0){l=char.ToUpper(l);p++;}t=$"{t}{l}";}}
```
[Try it online!](https://tio.run/##VY7BSgMxGITP3af4DR4Sirul15CTLHiotrRZVMRDSNPdQDZZkmiVkGdf03rRuc3MNzAy3Enn1Tx/BG17OHyHqEZaSSNCgJ13vRcjpGoRoohawqfTR3gU2uIQfRm8vYPwfSAXBIp@UwjAAA3KGEShaXYdh9dttwfevnB4aPct8G0xB/5vFBlCVNsIE1vR86CNwtMNC/VG2T4OzZqkK3FpT@WykAOWg/AgQVsIJF2NYZLqE7bqDHthj27EpH5SXxGvCWMrkkpfsJq7bpqUx4bQabmkObJblGJOJiOacwV/dO9scEbVz15HtdFW4UhotchVnucf)
[Answer]
# [Python 2](https://docs.python.org/2/),127 119 bytes
Not super happy with this, I'll probably come back to it after class (or not, we'll see). Takes input from stdin using Python 2 `input()` rules - aka `"test"` rather than `test`.
Requires Python 2 for `range` returning a list, since that would require `*x,` instead of `x` otherwise, and would lose a byte on the print statement and I don't think you can gain more than 2 from inline variable assignments.
Using `chr`/`ord` is shorter than `[s[i],s[i].upper()][i in x[::2]]`, I think that's optimal as well.
Thanks to enzo for -8, from switching from using a while loop to just `str.join`.
```
from random import*
s=input()
n=len(s)
r=range(n)
x=sample(r,n)
print''.join(chr(ord(s[i])-32*(i in x[::2]))for i in r)
```
[Try it online!](https://tio.run/##HYpBCoMwEADveUXw4q60PaQ3IS8RD1Jj3WJ2wyaCfX0aehpmmPQtu7CrdVOJVhdeGygm0TKY7InTWQAN@yMwZDTq2/MOwGgun5eYjgB6a5aUuPT94yPE8NoVRFfIE814f7oByBLbaxpHNyNuovYfFGvtSsil@wE "Python 2 – Try It Online")
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 9 bytes
```
ẏṖ℅Ih⁽N¨M
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLhuo/huZbihIVJaOKBvU7CqE0iLCIiLCJzdHJpbmciXQ==)
Explanation:
```
ẏ         # List of [0..len(input))
 Ṗ℅       # Random permutation
   Ih     # First half of the list
     ⁽N¨M # Toggle case of the indexes in the list
```
There is actually a dedicated builtin for `Random Permutation`, which is faster, but there is a bug in it, so we have to get every permutation and choose a random one.
[Answer]
# [Python 3](https://docs.python.org/3/), 105 bytes
```
lambda s:''.join([x,x.upper()][y%2]for x,y in zip(s,sample([*range(len(s))],len(s))))
from random import*
```
[Try it online!](https://tio.run/##LYpBDsIgEADvvoKL6dKQHvRm4ktqDxjAYmB3s9BI/Tz24GkmmeG9roTXHu6Pnmx@OqvKbRimN0WEuZk2bcxeQC/zfr4sgUQ1s6uI6hsZiik2c/Iwj2Lx5SF5hKL1Yv6i9SkIZXVUdyBmJqljZ4lYIUBE3iocV199SvQhSa7/AA "Python 3 – Try It Online")
[Answer]
# Excel, 89 bytes
```
=LET(x,LEN(A1),y,RANDARRAY(x),CONCAT(CHAR(CODE(MID(A1,SEQUENCE(x),1))-(y>MEDIAN(y))*32)))
```
This breaks the string into an array of characters. Then generates an array of random numbers of the same length. For each number in the random array that is greater that the median of the array, the corresponding letter is changed to upper case (ASCII value reduced by 32). Then all of the characters are concatenated.
[Answer]
# [Perl 5](https://www.perl.org/) `-pF`, 43 bytes
1 byte saved thanks to [@Kjetil S](https://codegolf.stackexchange.com/users/64733/kjetil-s)!
```
$F[rand@F]&=_,$_=join"",@F
while@F/2>y;A-Z;
```
[Try it online!](https://tio.run/##K0gtyjH9/1/FLbooMS/FwS1WzTZeRyXeNis/M09JScfBjas8IzMn1cFN38iu0tpRN8r6///EpOSU1LT0jH/5BSWZ@XnF/3UL3AA "Perl 5 – Try It Online")
---
# [Perl 5](https://www.perl.org/) + `-pa`, 38 bytes
-5 bytes using a space separates string (Thanks [@Kjetil S](https://codegolf.stackexchange.com/users/64733/kjetil-s)!)
```
$F[rand@F]&=_,$_="@F"
while@F/2>y;A-Z;
```
[Try it online!](https://tio.run/##K0gtyjH9/1/FLbooMS/FwS1WzTZeRyXeVsnBTYmrPCMzJ9XBTd/IrtLaUTfK@v//RIUkhWSFFIVUhTSFdIWMf/kFJZn5ecX/dQsSAQ "Perl 5 – Try It Online")
[Answer]
# [ayr](https://github.com/ZippyMagician/ayr), 13 bytes
```
(];-){:2|#?.#
```
[Try it!](https://zippymagician.github.io/ayr#Zjo@/KF07LSl7OjJ8Iz8uIw@@/Oz5mIjEwJEAuMCBfMV0nYWJjZGVmZ2gn//)
# Explained
```
       #?.# Roll N-sided die N times, where N is len of y
     2|     Convert this to a length-N boolean vector (half 1s, half 0s)
   {:       Use this to catalogue..
];-         A matrix of the string and the string with inverted caps
```
[Answer]
# [Raku](http://raku.org/), 41 bytes
```
{[~] {@_[pick @_/2,^@_]».=uc;@_}(.comb)}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/OrouVqHaIT66IDM5W8EhXt9IJ84hPvbQbj3b0mRrh/haDb3k/Nwkzdr/xYmVCmka6mn5@UmJReqaCmn5RQpxhgb/AQ "Perl 6 – Try It Online")
* `.comb` splits the input string into a list of characters, which is then fed to the brace-delimited anonymous function, which takes the list in the `@_` array. This is just a short way to get an array with writeable elements without having to declare one explicitly.
* `pick @_ / 2, ^@_` randomly selects half of the indices in the character array.
* `@_[...]».=uc` slices into the array of characters with the random selection of indices, and uppercases the characters at those indices. The original array is then returned.
* `[~]` concatenates the characters into a single string.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 20 bytes
```
Ｗ⁻⊗ＬΦＫＡ№ακＬθＰ⭆θ‽⁺κ↥κ
```
[Try it online!](https://tio.run/##LY1BCsIwEEWvMsspxBO4EsWVgaL0AGM6tEPGJE0TPX4M4t88Pjz@dytlF0lb@6yiDGgl1B0vsT6VZ7xxWMqKV9HCGUdmf1LFwcA51lCQDPihx8Bf3HoBW7VIytKFR@lYLCXcDNwpzPGFo/YDb2BKibOjnfG3MRxbc5SkkMrO7fDWLw "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
Ｗ⁻⊗ＬΦＫＡ№ακＬθ
```
Repeat until uppercase letters make up exactly half of the canvas...
```
Ｐ⭆θ‽⁺κ↥κ
```
... output the input string but randomly uppercase each letter.
[Answer]
# APL+WIN, 37 bytes
Prompts for string
```
s[i]←s[i←(.5×⍴s)?⍴s←⎕av⍳⎕]+48⋄⎕av[s]
```
[Try it online!Thanks to Dyalog Classic](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qvz6O2CcZcQJanP5BlyPWooz3tf3F0ZiyQB6SApIae6eHpj3q3FGvag0igCFB1Ytmj3s1AOlbbxOJRdwtYJLo4lus/UD/X/zQu9cSk5JTUNHUA "APL (Dyalog Classic) – Try It Online")
[Answer]
# Python 3, 124 bytes:
```
import random as r
j=range
f=lambda s:(lambda v:''.join(chr(ord(s[i])-32*(i in v))for i in j(l)))(r.sample(j(l:=len(s)),l//2))
```
[Answer]
`(new Array(s.length)).fill(0).map((i,j)=> j % 2).sort(() => Math.random() - 0.5).map((i, j) => (i ? s[j].toUpperCase() : s[j])).join("")`
[Answer]
# [Ly](https://github.com/LyricLy/Ly), 44 bytes
```
irysp>l[0f1f,,]p<[>sprl0y?[,sprl]psp<l' *-o]
```
[Try it online!](https://tio.run/##y6n8/z@zqLK4wC4n2iDNME1HJ7bAJtquuKAox6DSPloHxIgtKC6wyVFX0NLNj/3/vzg/N7UkIzMvPbM4I7GgIDUPyAQA "Ly – Try It Online")
This one works by generating a list of `0 1` pairs on a list the size of the input string. Then for each input character it reverses the list of `0 1` pairs a random number of times, then pops the top off the resulting stack. That value is used to decide whether or not to capitalize the character before printing it out.
1. Prep the input strings
```
ir      - read input codepoints into the stack, reverse the stack
  ysp   - save the number of char, delete that from the stack
     >  - switch to an empty stack
```
2. Generate a list of `0 1` pairs
```
      l[0f1f,,]p
      l[    ,,]p  - loop "n/2" times adding "0,1" pairs to the stack
        0f        - add a "0" to the stack, pull the iterating var forward
          1f      - add a "1" to the stack and pull the iterator forward again
```
3. Process each of the input chars on the input stack
```
<[                         ] - loop until the input stack is empty
  *3.1*                      - get a random 0/1 from the boolean stack
                    <l       - back to input stack, load boolean 0/1 capitalization choice
                      ' *    - multiple " " by the boolean
                         -   - subtract to capitalize (of boolean was true)
                          o  - print the current input char
```
3.1 Pull a random boolean off the list
```
>                   - switch to the boolean stack
 sprl               - disrupt pattern on list, move top entry to the bottom
     0y?            - pick a random number between 0 and the stack size
        [,sp l]p    - loop that number of time, using backup cell for iterator val
            r       - reverse the stack
                sp  - save the random boolean to the backup cell
```
]