text:
Őőőőőőő, are you there?
Description
While support is getting better and better for people to write in various scripts around the world using unicode, and now you can even write in emojis as well, unfortunately most fonts[citation needed] are still missing Latin characters based on the double acute accent, which is required to write properly in Hungarian.
These characters are the following four:

U+0150 LATIN CAPITAL LETTER O WITH DOUBLE ACUTE (Ő)
U+0151 LATIN SMALL LETTER O WITH DOUBLE ACUTE (ő)
U+0170 LATIN CAPITAL LETTER U WITH DOUBLE ACUTE (Ű)
U+0171 LATIN SMALL LETTER U WITH DOUBLE ACUTE (ű)

Task
Your task is to write a program / script / function, that given a font or a font's name gives out a truthy value in case the font contains all of the four glyphs described above, or a falsey value if at least one of them is missing from the font.
Scoring
This is code-golf, so lowest byte-count wins
Test cases
These fonts are from Google Fonts. Note that some fonts on Google Fonts (for example Lato) have an updated version on other sites which already contain the missing glyphs, if you have the updated ones then obviously your results might be different from the test cases below.
Truthy values:
Roboto
Open Sans
Lalezar
Source Sans Pro
Arial
Times New Roman
Cinzel

Falsey values:
Voltaire
Rosario
Heebo
Bitter
Arvo
Lato (see note above)
Molengo (contains ű and Ű, but not ő or Ő)
Sue Ellen Francisco (contains only the uppercase variants)
Germania One (contains only the lowercase variants)
Garamond (the one installed on OSX by Office for Mac)

Notes

It's up to you if your program requires a font's name as a parameter or the actual font (or the font's location on the system)
If it's a font's name the program should check the system font registered at that name (for example if you specify "Arial" it should use the Arial font in your system's font registry)
If it's a location the program should use that specific font, even if there is a system font registered with that same name (for example if you specify "/home/user/Arial.ttf" it should use that font even if there's an Arial registered in the system's store)
Google Fonts above is just a convenient place you can download fonts for testing purposes, but your code doesn't need to use those fonts
It is enough if your program works with only one specific font type, e.g. TTF, OTF, WOFF, SVG font, Type 1, Metafont, etc. However you should support a font format that has generic support for the four glyphs and for signalling missing glyphs mentioned above, e.g. you cannot chose a font format where the answer will always be falsey or truthy
Some fonts might have the above glyphs incorrectly hardcoded to a fake value (e.g. the replacement box) instead of not specifying in the font file at all. Your code doesn't need to be able to differentiate between a fake glyph and a real glyph, but it's also acceptable if it does the check based on that.

Please specify in your answer how you have to pass in the font, and what kind of fonts it works with.

You might want to close the loophole around choice of font type to support. I've worked with font systems for which 0 would be a valid answer in many languages...

@totallyhuman No, that's just a convenient place you can download TTF/OTF fonts for you to test. As stated the code should work with either system fonts or a locally available font file.

@PeterTaylor good note, I added the exclusion

Scala, 56 bytes
s=>new java.awt.Font(s,0,0).canDisplayUpTo("ŐőŰű")<0

canDisplayUpTo is a method of the Font object that returns the index of the first charater that cannot be displayed by the font. It return -1 if all characters can be displayed. javadoc

Java has a builtin Mathematica doesn't have?

If I'm not mistaken, this is valid Java if you replace = with -. Too similar for me to post a separate answer :)

Mathematica, 80 72 76 bytes
xFreeQ[f=Rasterize@Style[#,FontFamily->x]&;f/@("Ő""ő""Ű""ű"),f@"�"]

Takes the name of a font as a string. For each of the characters in question, generates an image of the character in the given font, and checks if they're all different from a similar image of the replacement character "�".
(The other weird character, , is \[Function].)
In almost all cases, the following 67-byte solution works instead:
xLength[Rasterize@Style[#,FontFamily->x]&/@("Ő""ő""Ű""ű")]>3

Here, we just check if all four images are different, which is valid under several assumptions about the fonts:

If the font can actually represent these characters, the results are all different.
If it fails to represent one of them, it fails on at least two (both the lowercase ones, or maybe "Ő" and "ő" but not "Ű" and "ű") replacing them both by the same "�"-looking character.

Unfortunately, the first assumption fails in very rare cases. For example, maybe the font doesn't distinguish between uppercase and lowercase characters. One example of this is a variant of EB Garamond, "EB Garamond 12 All SC". (On my laptop, there are 360 fonts installed, and this is the only one of them that the second solution fails on.)
Neither solution can be tried on Try It Online because the script version of Mathematica, unsurprisingly, has no support for different fonts. If you have Mathematica installed and want to try this, the system variable $FontFamilies lists the valid inputs (the fonts you have installed).

-4 bytes thanks to Martin Ender

C# (Visual C# Compiler), 107 100 + 23 bytes
-7 bytes thanks to briantist, whose Powershell answer helped me realise I'm a dummy and can shave off some bytes.
s=>"ŐőŰű".All(x=>new Windows.Media.GlyphTypeface(new Uri(s)).CharacterToGlyphMap.ContainsKey(x))

+23 bytes from
namespace System.Linq{}

It takes path to a font file (local or internet uri), and only supports OpenType fonts. Unfortunately doesn't work on TIO because it needs reference to PresentationCore.dll, but here's the full program code anyway:
LINK
Explanation:
GlyphTypeface class loads font from provided uri, CharacterToGlyphMap loads all possible characters to a map, in which the characters are the keys. So we just take every tested character and check if the keys exist (which means the font supports them).

Nice! I didn't realize you could leave off System. without a using System; in C#.

@briantist I could because I put the program inside System.Linq namespace. When looking for types, compiler will look in your namespace's whole hierarchy, so first it will try to find it in System.Linq and then in System. (I'm simplifying, it probably is more intricate, but you get the gist) - that's also why I could use Uri without System.Uri or using System; as well

PowerShell, 86 bytes
([Windows.Media.GlyphTypeface]::new("$args")|% C*p|? K* -in 336,337,368,369).Count-eq4

This is a shameless port of Grzegorz Puławski's Answer in PowerShell, using some golfing tricks.
I'm confident this could be golfed further but I have run out of time at the moment.

I approve of this message. +1


text:
Random Capitalization
The Task
Your task is to create a program or a function that, given an input, outputs the input text with random letters capitalized, while keeping already capitalized letters capitalized.
Every combination of capitalizations of the lowercase letters should be possible. For example, if the input was abc, there should be a non-zero probability of outputting any of the following combinations: abc, Abc, aBc, abC, ABc, AbC, aBC or ABC.
Input
Your input is a string, containing any number of printable ASCII characters, for example Hello World. The outputs for that input include HeLLo WoRlD, HElLO WOrld, etc.
Scoring
This is code-golf, so the shortest answer in each language wins!

It's possible for something to happen, yet still have zero probability. Link here. Does it just have to be possible, or does it need to to have a strictly non-zero probability, as stated?

@AviFS It's only possible for something that occurs to have zero probability if the number of possibilities is infinite. For any finite input, it's a moot point. And for any infinite input there are necessarily possibilities with 0 probability.

@Chris It may be true (though I don't get the piece about in/finite input.) But I promise my question still stands. The validity of the answer I have in mind is dependent on the answer.

@AviFS Well the OP hasn't been on the site in years,  so you're not likely to get a response from them. If you think your answer follows the rules as stated, I'd just post it if I were you. Either way I'd be interested to see your answer. ;)

From my reading, you can assume the input is always a finite string. So I don't see how you can have something that happens unless it has a non-zero probability.

Does the output has to be a string, or can it be an iterator? (For python.)

TI-Basic (83 series), 137 bytes
For(I,1,length(Ans
Ans+sub(sub(Ans,I,1)+"ABCDEFGHIJKLMNOPQRSTUVWXYZ",1+int(2rand)inString("abcdefghijklmnopqrstuvwxyz",sub(Ans,I,1)),1
End
sub(Ans,I,I-1

Takes input in Ans, as illustrated in the screenshot below:

(If the screenshot looks scrambled, as it sometimes does for me, try opening it in a new tab?)
TI-Basic (at least the TI-83 version... maybe I should branch out into TI-89 golfing) is a terrible language to try to golf this challenge in, since:

It provides absolutely no support for any arithmetic with characters, knowing the uppercase version of a lowercase character, or even knowing the alphabet.
Every single lowercase character takes 2 bytes to store. (In fact, I had to use an assembly script just to be able to type the lowercase letters.)

The result is that 78 bytes of this program (more than half) are just storing the alphabet, twice.
Anyway, the idea is that we loop through the string, with a chance of turning lowercase characters into uppercase ones as we go, and adding the result onto the end of the string so that both the input and the output are stored in Ans. When we leave the For( loop, I is one more than the length of the original string, so taking the I-1 characters starting at I gives the output.

The apps "MirageOS" and "OmniCalc" both allow you to type lowercase letters just by pressing alpha twice. And they also have other nice features.

@Fabian The assembly script, and the apps you mentioned, both work essentially the same way: they set a flag in the operating system that enables "press alpha twice for lowercase".

Python 2, 66 65 bytes
lambda s:`map(choice,zip(s.upper(),s))`[2::5]
from random import*

Try it online!

Japt, 6 bytes
®m`«`ö

Test it online!
Explanation
®m`«`ö   Implicit input
®        Map each char in the input by
 m         mapping each char in this char through
  `«`ö       a random character of "us". (`«` is "us" compressed)
             The u function converts to uppercase, and s is slice, which does nothing here.
         Implicit output

C,  47  46 bytes
Thanks to @l4m2 for saving a byte!
f(char*s){for(;*s++-=(*s-97u<26&rand())*32;);}

Try it online!
Would be 42 bytes, if it could be assumed that {|}~ don't appear in the input:
f(char*s){for(;*s++-=(*s>96&rand())*32;);}

Try it online!

Worth noting that, given a particular implementation, the capitalization is perfectly deterministic (the C standard provides an implicit srand(1) at the start of the program, so in each execution the sequence of values returned by rand() will be the same).

f(char*s){for(;*s++-=(*s-'a'<26&rand())*32;);} for some compiler (def. -funsigned-char) work

@l4m2 Thanks! That doesn't work though for some reason. Changing 'a' to 97u works and doesn't even require the -funsigned-char flag.

It seems that when you subtract 'a' (which is signed int, not unsigned char) from *s (which is unsigned char), *s gets promoted to signed int instead of unsigned int, hence negative values being possible and the comparison not working as intended.

Jelly, 5 bytes
Another one bytes the dust thanks to dylnan.
żŒuX€

Try it online!
Explanation
żŒuX€  main link: s = "Hello world"

żŒu    zip s with s uppercased  ["HH", "eE", "lL", "lL", "oO", "  ", ...]
   X€  map random choice        "HeLLo woRlD"

I need to use ŒṘ more often to see how things are represented under the hood

Perl 5, 23 bytes
22 bytes code + 1 for -p.
s/./rand>.5?uc$&:$&/ge

Try it online!

JavaScript (ES6), 56 bytes
s=>s.replace(/./g,x=>Math.random()<.5?x.toUpperCase():x)

If uniform randomness is not required, we can save 6 bytes by using the current time as the source of randomness:
s=>s.replace(/./g,x=>new Date&1?x.toUpperCase():x)

This tends to either uppercase or leave alone all letters at once.

"there should be a non-zero probability of outputting any of the following combinations: abc, Abc, aBc, abC, ABc, AbC, aBC or ABC", while yours can't output AbC because the time won't change so fast

@l4m2 if you have a really slow machine, it might ;-) Maybe I should just remove that part though...

R, 66 bytes
for(i in el(strsplit(scan(,""),"")))cat(sample(c(i,toupper(i)),1))

Try it online!
Another R answer.

I've been writing too much "regular" R code and didn't even think to try a for-loop! Nice one.

Charcoal, 8 7 bytes
⭆Ｓ‽⁺↥ιι

Try it online! Link is to verbose version of code. Explanation:
 Ｓ          Input string
      ι     Character
    ↥ι      Uppercase character
   ⁺        Concatenate
  ‽         Random element
⭆           Map over each character and join the result
            Implicitly print

Excel VBA, 74 71 64 Bytes
The Randomize call always makes random output costly in VBA :(
Anonymous VBE immediate window function that takes input from range [A1] and outputs to the VBE immediate window. Produces a 50% (on average) UCased output.
For i=1To[Len(A1)]:a=Mid([A1],i,1):?IIf(Rnd>.5,a,UCase(a));:Next

Hello Sir. you can save 2 bytes by removing Randomize: and changing Rnd with [RAND()>.5] . Or just ignore it. :)

@remoel, unfortunately, the [Rand()] call is only psuedo-random and has a period length of roughly 10^13, making it functionally identical to the un Randomized Rnd call, in fact the two use the same seed (which the Randomize call sets by using the timer function output).

@romoel, I do however suppose that given the clarifications on the prompt that I could remove the Randomize call and instead use Rnd>.5

Ruby, 40 Bytes
Lambda function that takes a string. Saved 1 byte thanks to Arnauld. Saved 5 bytes thanks to Snack.
->s{s.gsub(/./){|x|[x,x.upcase].sample}}

Welcome to PPCG! Could you save a byte with <1 instead of ==1?

40 bytes

Nice work @displayname. FWIW when users improve their score, many like to "cross out" the old score with the <s> tag, e.g. "Ruby, 46 40 bytes." Of course it's not required.

R, 89 88 bytes
outgolfed by djhurio!
cat(sapply(el(strsplit(scan(,""),"")),function(x)"if"(rt(1,1)<0,toupper,`(`)(x)),sep="")

Try it online!
This program takes each character, and with probability 1/2 converts it to uppercase or leaves it alone. It's possible to tweak this probability by playing with different values of df and 0.
rt draws from the Student's t-distribution, which has median 0 with any degree of freedom (I selected 1 since it's the smallest number possible).

That's a very R way of doing something at random.

66 bytes https://codegolf.stackexchange.com/a/149518/13849

@djhurio that's brilliant.

APL+WIN, 37 bytes
⎕av[c-((n÷2)<n?n←⍴s)×32×s←98<c←⎕av⍳⎕]

Prompts for screen input, identifies lower case letters and randomly converts them to upper case.

Java 8, 46 bytes
This lambda is from IntStream to IntStream (streams of code points).
s->s.map(c->c>96&c<'{'&Math.random()>0?c-32:c)

Try It Online
Capitalization distribution
Whether to capitalize a letter used to be the quite sensible condition that Math.random()<.5, which was satisfied about half the time. With the current condition of Math.random()>0 (which saves a byte), capitalization occurs virtually every time, which makes a test program kind of pointless. But it does satisfy the randomness requirement.
Acknowledgments

-1 byte thanks to Olivier Grégoire

If you go the stream route, you can use code points and do 41 bytes.

Well, that breaks if the input contains ASCII characters above z. I could throw it in with a qualification though.

Fix for 6 more bytes.

Wolfram Language (Mathematica), 52 49 44 bytes
StringReplace[c_/;Random[]<.5:>Capitalize@c]

Try it online!
Uses the operator form of StringReplace: providing it a rule (or a list of rules) but no string gives a function which applies that rule to any string you give it as input.
We could do a lot better (RandomChoice@{#,Capitalize@#}&/@#& is 34 bytes) if we decided to take as input (and produce as output) a list of characters, which people sometimes argue is okay in Mathematica because it's the only kind of string there is in other languages. But that's no fun.

-5 bytes thanks to M. Stern

Save one byte by using Capitalize

If you would ignore that Random is deprecated you could save another four bytes by implementing your own RandomChoice: StringReplace[c_/;Random[]<.5:>Capitalize@c],

@M.Stern I was trying to get Random to work at one point, but I forgot about the /; so I was trying to put into an If statement. Thanks!

05AB1E, 6 5 bytes
Thank you Adnan for -1 byte
uø€ΩJ

Try it online!
Explanation
uø€ΩJ
u      Upper case of top of stack. Stack: ['ZZZAA']
 ø     Zip(a,b) (uses implicit input). Stack: ['zZ', 'zZ', 'zZ', 'AA', 'AA']
  €    Following operator at each element of its operand
   Ω   Random choice. Stack: ['z', 'Z', 'z', 'A', 'A'] (for example)
    J  Join a by ''. Stack: 'zZzAA'
       Implicit output

Method taken from @totallyhuman's answer

Will anyone ever beat 6? :P

@ETHproductions If Jelly had a single byte operator for upper case like 05AB1E we would!

Ooo... New command for random_pick eh? ε„luΩ.V was my attempt, nice one!

You can leave the duplicate out :)

Will anyone beat 5? :P

@MagicOctopusUrn That was my first attempt too!

@totallyhuman yes. You can leave out the J since a list of characters is considered a string. Making this improvement ties you for #1 alongside @Shaggy. You're welcome in advance :)

Swift 4, 86 bytes
s.map{let s="\($0)",u=s.uppercased();return u==s ? u:arc4random()%2==0 ? u:s}.joined()

Welcome to PPCG!

Ruby, 39 bytes
->s{s.gsub(/./){[$&,$&.upcase].sample}}
Largely inspired from displayname's answer. (I couldn't comment to suggest this one-byte-less version for lack of reputation, sorry displayname)

Welcome to PPCG!

I wasn't expecting greetings, how nice! Thank you!

Funky, 55 bytes
s=>s::gsub("."c=>{0s.upper,s.lower}[math.random(2)](c))

Try it online!
Thanks to optional commas, it's one byte shorter to do 0s.upper in the table definition, which means the math.random will randomly pick either 1 or 2, than to do math.random(0,1) in the random and not have the 0.

R, 60 59 58 57 56 63 bytes
intToUtf8((s=utf8ToInt(scan(,"")))-32*rbinom(s,s%in%97:122,.5))

Try it online!
Different approach from the other two R answers here and here.
Improved and fixed thanks to Giuseppe!

I did not know the sampling functions behaved like that!

@Giuseppe Just when I thought this couldn't be golfed down...

57 bytes

@Giuseppe Not only is this golfier but also more elegant! Love it!

upon second view, this won't work when printable ascii characters above 90 like [, but this fixes it for +7 bytes which is still golfier than djhurio's answer

Dyalog APL, 23 18 17 14 bytes
This is a function which takes a string and returns it with random capitalization (as specified in the question).
{(?2)⌷⍵,1⎕C⍵}¨

Edits: Answer improved using suggestions by @LdBeth and @EliasMårtenson at the APL Orchard.
New Edit: Answer improved using suggestion by @Adam at APL Orchard.

Welcome to Code Golf, and nice first answer! Be sure to check out our Tips for golfing in APL page for ways you might be able to further golf your submission

@pxeger Thanks - I'll check out that page now! By the way, do you have any tips for improving this answer / reducing the character count?

Sorry, I don't know any APL, so I can't help you there. You coiuld ask in the APL chat room

@pxeger Thanks for your suggestion. As you suggested, I've posted on the APL chat room - let's see if I get any replies!

Alice, 17 15 bytes
Thanks to Leo for saving 2 bytes.
/uRUwk
\i*&o.@/

Try it online!
Explanation
/...
\...@/

This is the usual framework for largely linear programs operating entirely in Ordinal mode.
i    Read all input as a string.
R    Reverse the input.
&w   Fold w over the characters of the string. w is nullary which means it
     doesn't actually use the individual characters. So what this does is that
     a) it just splits the string into individual characters and b) it invokes
     w once for each character in the string. w itself stores the current
     IP position on the return address stack to begin the main loop which
     will then run N+1 times where N is the length of the string. The one
     additional iteration at the end doesn't matter because it will just
     output an empty string.
.    Duplicate the current character.
u    Convert it to upper case (does nothing for characters that aren't
     lower case letters).
*    Join the original character to the upper case variant.
U    Choose a character at random (uniformly).
o    Print the character.
k    If the return address stack is not empty yet, pop an address from it
     and jump back to the w.
@    Terminate the program.

I first tried doing this entirely in Cardinal mode, but determining if something is a letter just based on character code would probably take more bytes.

Pyth, 10 7 6 bytes
smO,r1

Saved 3 bytes thanks to ovs and 1 thanks to Steven H.
Try it online
Explanation
smO,r1
 m      Q   For each character in the (implicit) input...
   ,r1dd    ... get the capitalized version and the (implicit) character, ...
  O         ... and pick one at random.
s           Concatenate the result.

r1d=rd1, allowing you to implicit-input golf another byte out.

Ouroboros, 25 bytes
i.b*)..96>\123<*?2*>32*-o

Try it here
The only fancy part is the control flow, .b*). Let's talk about the rest first.
i..                    Get a character of input, duplicate twice
   96>                 Test if charcode greater than 96
      \                Swap with copy #2
       123<            Test if charcode less than 123
           *           Multiply the two tests (logical AND): test if it is lowercase letter
            ?          Random number between 0 and 1
             2*        Times 2
               >       Is lcase test greater? If test was 1 and rand*2 < 1, then 1, else 0
                32*-   Multiply by 32 and subtract from charcode to ucase lcase letter
                    o  Output as character

We then loop back to the beginning of the line. Control flow involves changing where the end of the line is; if it is moved to the left of the IP, execution terminates. Thus:
 .     Duplicate input charcode
  b*   Push 11 and multiply
    )  Move end of line that many characters to the right

When the charcode is positive, ) is a no-op, since the end of the line is as far right as it can go. But when all characters have been read, i gives -1. Then we move the end of the code -11 characters to the right--that is, 11 characters to the left. It takes a couple iterations, but eventually the IP is past the end of the code and the program halts.

MATL, 12 11 bytes
"@rEk?Xk]v!

Try it online!
Saved 1 byte thanks to @LuisMendo

Brachylog, 5 bytes
ụᶻṛᵐc

Try it online!
Explanation
Example input: "Test"

ụᶻ        Zip uppercase:      [["T","T"],["e","E"],["s","S"],["t","T"]]
  ṛᵐ      Map random element: ["T","e","S","T"]
    c     Concatenate:        "TeST"

PowerShell, 57 56 bytes
-join([char[]]"$args"|%{(("$_"|% *per),$_)[(Random)%2]})

Try it online!
-1 byte thanks to briantist
Takes input as a string, explicitly casts the $args array to a string, casts it as a char-array, then feeds the characters through a loop. Each iteration, we 50-50 either output the character as-is $_ or convert it to upper-case "$_".ToUpper() (that's the ("$_"|% *per) garbage). That's chosen by getting a Random integer and taking it mod 2.
Those characters are left on the pipeline and then -joined back together into a single string, which is itself left on the pipeline and output is implicit.

You can save a single byte changing "$_".ToUpper() to ("$_"|% *per) :-/

@briantist Good thing we don't care about readability. ;-) Thanks!

PHP, 63 53 bytes
while($a=$argv[1][$i++])echo rand()%2?ucfirst($a):$a;

Managed to reduce the code with 10 bytes by (partialy) following Titus' suggestion.

Nice one! No need for a space before $a. Try while(~$a=$argn[$i++]) instead of foreach (run as pipe).

Using that code i got a "Uncaught Error: Unsupported operand types" error. And i cant see why it does that, but i suspect the ~. (and maybe because i use PHP7 and the method only works for 5.6)

Julia, 35 bytes
s->map(c->rand([c,uppercase(c)]),s)

Try it online!
Still pretty easy to read as a human.
In Julia rand(A) returns a random element from A.

Welcome to PPCG!

APL (Dyalog Unicode), 28 bytes
28 bytes (https://github.com/abrudz/SBCS/)
50 bytes (UTF-8)
{1(819⌶)@(?n⍴⍨?n←≢⍸~⍵∊⎕A)⊢⍵}

Inspired by Graham's APL+Win solution
Try it online!

Vyxal s, 6 5 4 bytes
⇧Zv℅

Explanation:
⇧Zv℅    # main program

⇧       # converts the input to uppercase
 Z      # zips the implicit input with the uppercase version
  v℅    # vectorized choose over the list

s flag  # concats the stack and prints

Try it Online!
-2 (and fixed) thanks to @lyxal

Try it Online! for 5 bytes

@lyxal I like how that is the intended use case for that character, yet I still managed to not use it lol; updated

Turns out that your 6 byter wasnt valid. Here's a 4 byte version that is

@lyxal I think im having a brain moment, because I misinterpreted the challenge again. if you want to post your own answer as a separate post, that's fine and I'll delete mine, just lmk.

Uppercase stays uppercase, everything else is randomised

@lyxal ik, post your answer separately, cause I didn't contribute to it at all, and ill delete this one

No, I want you to keep your post. Take the 4 byter... ƛ...℅ is close enough to v℅ lol

Python 3, 74 66 bytes
-8 bytes thanks to @Jakque
lambda s:"".join(map(choice,zip(s.upper(),s)))
from random import*

Try it online!

I've edited in a link to Attempt This Online so that other users can try out your code. (Other services are available)

You can also save 2 bytes by choosing the methods themselves at random, rather than their results

81 bytes building off of pxeger's and not using map

Actually, 74 bytes using map(choice,zip(s.upper,s.lower))

while keeping already capitalized letters capitalized. so you can just do : lambda s:"".join(map(choice,zip(s.upper(),s))) and save 8 bytes

Rebol, 61 bytes
u:func[t][n: random length? t t/(n): uppercase t/(n) print t]

Test:
>>c: "Test sTring"
>>u c
Test sTriNg

Jelly, 16 bytes
2ḶXø³L¤Ð¡ḊT
Œu¢¦

Try it online!
Explanation
2ḶXø³L¤Ð¡ḊT    First Link
2Ḷ             The list [0,1]
  X            Random element (1 is truthy, 0 is falsy)
   ø           Begin nilad
    ³L         Length of first input (the string)
      ¤        End nilad
       Ð¡      Random([0,1]) for each character in the input string and collect.
         Ḋ     The list had an extra None at the beginning. Don't know why. This removes it (the first element of the list)
          T    Get indices of all truthy

Œu¢¦           Main Link
Œu             Capitalize
   ¦           At the indices in the list:
  ¢            The first link as a nilad (list of indices)

I couldn't get this to work in a single line. I also don't know why, but 2ḶXø³L¤Ð¡ gives the list [None,1,0,..,1] with 0s and 1s chosen randomly. The None is the reason for the Ḋ in the first link.

Pyth, 5 bytes
sOVr1

Try it here!
A translation of totallyhuman's Jelly answer.
Explanation:
sOVr1QQ  Implicit inputs.
   r1Q   Upper(input)
  V   Q  Zip with itself and map...
 O       Random choices between r1Q and Q.
s        Sum the results back into a string.

Perl 6, 28 bytes
{S:g/.<?{rand>.5}>/{$/.uc}/}

Try it online!
S:g/./{$/.uc}/ itself would convert every individual character to uppercase.  Including the regex assertion <?{rand > .5}> assures that the replacement happens only half of the time.

APL (Dyalog), 16 bytes
Tacit prefix function. Requires ⎕IO (Index Origin) to be 0, which is default on many systems.
{?2:⍵⋄1(819⌶)⍵}¨

Try it online!
{…}¨ apply the following function on each character:
 ?2: if random 0 or 1:
  ⍵ return the argument unmodified
 ⋄ else:
  1(…)⍵ apply the following function with 1 and the argument as arguments:
   819⌶ case-fold (left argument 1 means uppercase)

Kotlin, 54 bytes
{it.map{if(Math.random()<.5)it else it.toUpperCase()}}

Try it online!
The type of this function is (List<Char>) -> List<Char>.

Octave, 44 bytes
@(x)['',x-32*(x<123&x>96&rand(size(x))>.5)];

Try it online!

Python 3, 92 bytes
lambda x:''.join([i.upper() if getrandbits(1) else i for i in list(x)])
from random import*

I tried it out using list comprehension and getrandbits for a random sort. I'm not sure if there is a shorter way to get a random boolean, but I'd love to know because getrandbits looks ugly to me and with the import takes up a lot of bytes.
Try it online!

Hi there and welcome to PPCG! I've added a language flag to the body of your response (to add keyword highlighting), but there are a few things that you should consider adding yourself such as a TIO Link and a description of how your code works.

@taylor Thanks! I'm a longtime lurker but its my first time submitting.

Factor, 70 bytes
Oh, Factor, so awesomely verbose...
USING: sequences ascii random ; [ dup ch>upper 2array random ] map

It's a quotation (lambdas did count as functions, right?), takes a string in the stack, call (or call( a -- b ) does its thing.
Its thing is leaving a new string on the stack, with random capitalization.
"Capitalize on my Capitals in the Capital" swap call .
 -> "CaPItALIZe oN mY CAPitaLs iN The CAPiTAl"
"Capitalize on my Capitals in the Capital" swap call .
 ->"CaPItAliZe ON mY CApItAls in ThE CapiTal"
...

As a word with comments (because why not!):
USING: sequences ascii random ; ! import the relevant vocabs (factor does it for you in the
                                ! listener, but the rules)
: random-case ( s -- s' )   ! declaration: string -> string'
   [ dup                    ! make a quotation to:
     ch>upper               !  dup a character and make the dup upper
     2array                 !  put them in an array
     random ]               !  and picks one at random
   map ;                    ! now use that to do the thing

"The confusing case of mixed cases in a case!" random-case
 -> "The coNFUsinG case OF Mixed caSes In A CASE!"

Taxi,  1183  1151 bytes
0 is waiting at Starchild Numerology.2 is waiting at Starchild Numerology.Go to Starchild Numerology: w 1 l 2 r, 1 l, 1 l, 2nd l.Pickup a passenger going to Firemouth Grill.Pickup a passenger going to Firemouth Grill.Go to Firemouth Grill: w 1 r 2 r 1 l 1 r.Go to Post Office: e 1 r.Pickup a passenger going to Chop Suey.[l]Go to Firemouth Grill: n 1 l.Pickup a passenger going to Cyclone.Go to Cyclone: w 1 l 1 r 2 r.Pickup a passenger going to Firemouth Grill.Pickup a passenger going to The Underground.Go to Zoom Zoom: n.Go to Firemouth Grill: w 3 l 2 l, 1 r.Go to The Underground: e 1 l.Switch to plan "k" if no one is waiting.Pickup a passenger going to Riverview Bridge.Go to Riverview Bridge: n 3 l.Go to Chop Suey: e 2 r.Pickup a passenger going to Auctioneer School.Go to Auctioneer School: s 1 r 1 l 3 r 1 l 1 l.Pickup a passenger going to Post Office."\0" is waiting at Writer's Depot.Go to Writer's Depot: n 1 l 1 r.Pickup a passenger going to Chop Suey.Go to Post Office: n 1 r 2 r 1 l.Switch to plan "l".[k]Go to Chop Suey: n, 2 r 1 l.Pickup a passenger going to Post Office.Go to Post Office: south, 1 r 1 l 2 r 1 l.Switch to plan "l".

Errors at end of input.
Try it online!
Ungolfed:
0 is waiting at Starchild Numerology.
2 is waiting at Starchild Numerology.
Go to Starchild Numerology: west, 1st left, 2nd right, 1st left, 1st left, 2nd left.
Pickup a passenger going to Firemouth Grill.
Pickup another passenger going to Firemouth Grill.
Go to Firemouth Grill: west, 1st right, 2nd right, 1st left, 1st right.
Go to Post Office: east, 1st right.
Pickup a passenger going to Chop Suey.
[loop]
Go to Firemouth Grill: north, 1st left.
Pickup a passenger going to Cyclone.
Go to Cyclone: west, 1st left, 1st right, 2nd right.
Pickup a passenger going to Firemouth Grill.
Pickup a passenger going to The Underground.
Go to Zoom Zoom: north.
Go to Firemouth Grill: west, 3rd left, 2nd left, 1st right.
Go to The Underground: east, 1st left.
Switch to plan "don't capitalize" if no one is waiting.
Pickup a passenger going to Riverview Bridge.
Go to Riverview Bridge: north, 3rd left.
Go to Chop Suey: east, 2nd right.
Pickup a passenger going to Auctioneer School.
Go to Auctioneer School: south, 1st right, 1st left, 3rd right, 1st left, 1st left.
Pickup a passenger going to Post Office.
"\0" is waiting at Writer's Depot.
Go to Writer's Depot: north, 1st left, 1st right.
Pickup a passenger going to Chop Suey.
Go to Post Office: north, 1st right, 2nd right, 1st left.
Switch to plan "loop".
[don't capitalize]
Go to Chop Suey: north, 2nd right, 1st left.
Pickup a passenger going to Post Office.
Go to Post Office: south, 1st right, 1st left, 2nd right, 1st left.
Switch to plan "loop".

Tricky things:

Although one cannot declare an empty string waiting, one can declare a null byte waiting, and that gets turned into an empty string, where it gets harmlessly dropped off at Chop Suey.
The whole hack is needed anyway to avoid running out of gas, because Auctioneer School is SO FAR AWAY from the rest of Townsburg.

Japt -m, 5 4 bytes
pu ö

Try it
pu ö     :Implicit map of each character of input string
p        :Append
 u       :  Uppercase
   ö     :Select random character

Python 3, 114 107 bytes
from random import *
for i in input():
	if random()>0.5:
		print(i.upper(),end="")
	else:
		print(i,end="")

Try it online!

Welcome to the site.  This answer has a lot of extra whitespace.  You might want to play around with python to figure out what whitespace is necessary and what is not.

Also both >1 and <2 are shorter than ==1 and both work just fine.

Also, you can replace randint(1 2) with random() for - a few bytes. Yes, it has an only one in 2^52 chance of capitalizing, but that does not matter because the challenge only requires that "Every combination of capitalizations of the lowercase letters should be possible"

You can remove >.5 for -4 bytes, following the same logic as my previous comment

Poetic - 735 bytes
alphabet:a-z
words i say,i spell
i say a letter of ABCs
i do know A,i sorta do
then it begins to turn fuzzy or vague-it was never clear
is the after-A letter B
the thing after B?gosh,i am stupid
i say C
D after C?yes,i nailed it
i keep a tally
if i try,i am great
i say a letter,all in order of a song
i heard it,how a letter is in there:A,B,then C
vowels are not a worry for me
vowels are easy
i wrote a huge E in upper-case,and a letter F
i failed with consonant G
still,i say,i penned a big H,I,and J
after J came K,or maybe L
i almost am half completed with everything
just need this difficult novel to read
o sorry,i am stupid,it is truly quite long
M is after L
N,then O
after O is harder letters
letters which really confused me

Try it online!
Poetic is an esolang I made in 2018 for a class project. It's basically brainfuck with word-lengths instead of symbols.
The point of the language is to allow for programs to be written in free-verse poetry. I made this poem about being confused about the alphabet, because it sounds funny.
There is a command that generates a random byte from 0 to 255, but the hard part was calculating that byte mod 2, and capitalizing or not capitalizing based on the result. This is a slow way of doing it, and it takes a while to run in the online interpreter.

Python 3, 59 bytes
i=input()
while i:print(end={i,i.upper()}.pop()[0]);i=i[1:]

Try it online!
Uses set.pop() to randomize. Note that this will only be random when used in a full program. Learn more.
The code can be reduced to a 47-byte function, but then it is only randomized once per input per session.
f=lambda i:i and{i,i.upper()}.pop()[0]+f(i[1:])

Try it online!

Or, alternatively, as a reusable function:
Python 3, 70 bytes
from random import*
f=lambda i:i and choice((i,i.upper()))[0]+f(i[1:])

Try it online!

This doesn't work with mixed case inputs. Additional nitpicking: set.pop() is not necessarily random. It is only guaranteed by the spec to be arbitrary.

@Beefster thanks for the feedback! The challenge asks you to keep uppercase characters as they are and to only randomize the lowercase input. That is exactly what my code is doing. Additionally, set.pop() picks an item based on hash value. In Python 3, the hash values for strings are completely randomized for a given session. Since this code qualifies as a full program, it will give a proper random output every time it is run.

@Beefster I did some further research and found that hash randomization for strings was made default in Python 3.3. You may want to check out this answer on Stackoverflow.

05AB1E, 4 bytes
Ties Shaggy's Japt answer and Underslash's Vyxal answer for #1.
uø€Ω

Try it online! Outputs as a list of characters.
uø€Ω  # full program
   Ω  # random character of...
  €   # each element of...
      # implicit input...
 ø    # with each character paired with corresponding character in...
      # implicit input...
u     # in uppercase
      # implicit output

Ly, 42 bytes
&ir[:(123)Lf'`Gfp*:[pp509?Gfp0]p[p' -0]po]

Try it online!
Pretty straightforward logic here... For each character, checks to see if it's in a-z.  If so, then it generates a random number in 0-9 and if that's less than 5, it converts the character to uppercase.
&ir[:(123)Lf'`Gfp*:[pp509?Gfp0]p[p' -0]po] #
&ir                                        # Read input into stack, and reverse it
   [                                    o] # Loop over each, printing to consume from stack
    :(123)L                                # Duplicate char, push ("z"+1) and compare
           f                               # Flip top two, to pull char to top
            '`G                            # Push ("a"-1) and compare
               fp*                         # Flip, pop char, combine test results
                  :[         0]p           # "If/Then" codeblock, test is "ch in a-z"
                    pp                     # Clean up stack
                      509?G                # Generate random number, compare to 5
                           fp              # Flip and pop to delete the 5
                                [p   0]p   # "If/Then" codeblock, test is "rand<5"
                                  ' -      # Subtract 32 " " from char to make uppercase
                                        o  # Print the current codepoint as a character

Knight, 42 bytes
;=xP Wx=xSxO+A-Ax*%R2*32&<96Ax>123Ax"\"T""

Try it online!
; = line PROMPT
# loop while line is non-empty
: WHILE line {
   ; OUTPUT(
     + ASCII(
         # Subtract from the ASCII of the first char of line
         - ASCII(line)
           # the product of
           *
             # rand() % 2
             % RANDOM 2
             # and the product of
             *
               # 'a' - 'A'
               32
                 # and islower(x) coerced to Number
                 & < 96 ASCII(x) > 123 ASCII(x)
          # or in short, islower(x) ? rand() % 2 * 32 : 0
      )
      # Backslash to suppress newline
      "\" # " # this comment is brought to you by SE syntax highlighting
    )
  # Then pop the first char from line
  # We actually abuse the NULL return value from
  # OUTPUT to shorten stuff.
  : = line SUBSTITUTE(line 0 1 "")
}

Mathematica, 56 bytes
Thanks to @ovs's feedback, the answer was cut down to 56 bytes by mapping Characters over ToUpperCase.
""<>RandomChoice/@Thread[Characters/@{ToUpperCase@#,#}]&

Mathematica, 60 bytes
I feel like this can be shortened, especially the logic around ToUpperCase and Characters.
We save bytes by aliasing Characters, using ""<>" over StringJoin, and using prefix notation.
c=Characters;""<>RandomChoice/@Thread@{c@ToUpperCase@#,c@#}&

Try it online!

You can save a few bytes by mapping Characters over {ToUpperCase@#,#}: Try it online!

MathGolf, 7 5 bytes
{_δαw

-2 bytes thanks to @ovs.
Try it online.
Explanation:
{      # Foreach over the characters in the (implicit) input-string:
 _     #  Duplicate the current character
  δ    #  Titlecase it
   α   #  Pair the two characters together
    w  #  Pop and push a random character from this pair
       # (after the loop, the entire stack is joined together and output implicitly)

{_δ+w works for 5 ;)

@ovs Smart, taking advantage of MathGolf's implicit join of the stack. :) Thanks.

SOGL V0.12, 6 bytes
{1ψ⌡Up

Try it Here! - the rest of the code there is the name of the function and calling of the function, as this expects the input on the stack.
Explanation:
{       for each character
 1ψ       push a random number from 0 to 1
   ⌡      that many times
    U       uppercase the letter
     p    print that character

Pip, 12 9 bytes
RC_.UC_Mq

Takes input from stdin. Try it online!
Explanation
        q  Read a line of stdin
       M   Map this function to its characters:
RC           Random choice from
  _          The character
   .         Concatenated to
    UC_      The character, uppercased
           Autoprint the resulting list, by default joined into a string

Haskell, 112 bytes
Two really expensive imports and one annoying type annotation :(
import Data.Char
import System.Random
mapM(\(b,c)->(c#)<$>randomRIO b).zip(repeat(0::Int,1))
a#1=toUpper a
a#_=a

Try it online!

Befunge, 2x21 = 42 Bytes
~:1+!v >-# " "$#?+#_,
    @_::"`"`\"{"\`*^

Try It Online
How it works:
~:1+!v
    @_

Gets input and ends program if empty.
      ::"`"`\"{"\`*^

Duplicates the input and checks whether it is in-between "`" and "{", i.e the lowercase letter range
       >-# " "$#?+#_,

Randomly chooses between subtracting a " " to make it uppercase, or just printing the character as is before returning to the start

Scala, 44 bytes
s.map(c=>if(math.random<.5)c.toUpper else c)

AWK, 100 79 73 bytes
BEGIN{FS="";srand()}{for(;i++<=NF;){rand()>.5?$i=toupper($i):i;printf$i}}

Try it online!

Cubix, 54 bytes
;'aW..@;.'zi?>o....;.;?-/..>;.>D<.\;>^u?-/.W;-;/S.;..u

Try it online!
Watch the interpreter in action!
The cost of checking whether a character is a lowercase letter or not in Cubix is quite high, but I'm happy I finally got to use D in a program!
For each lowercase letter in the input, there is a 50% chance that it will be uppercased, and a 50% chance it will be left alone.
Expands to the following cube:
      ; ' a
      W . .
      @ ; .
' z i ? > o . . . . ; .
; ? - / . . > ; . > D <
. \ ; > ^ u ? - / . W ;
      - ; /
      S . ;
      . . u

And a brief explanation of code flow is as follows:
'z               : push ascii z (122)
i                : read in input as code point, or -1 if end of input
?                : turn left if negative, turn right otherwise
 negative:
  @              : end program
/-               : reflect and subtract, result is negative if input is after z, positive if less, zero otherwise
?                : left if negative, right if positive, straight if zero
 negative:
  \;>^.          : pop top of stack and then head to output step
 positive:
  z              : no-op
  W              : jump left
  ;'a            : pop top of stack and push ascii a (97)
  /-             : reflect and subtract. Result is positive if input is between a-z exclusive, negative if before a and zero if a
  ?              : left if negative, right if positive, straight if zero
   negative:
    \;u;^        : stack manipulation and head to output step
   zero:
    u            : u-turn and head to positive branch
   positive:
    >            : point right
    ;            : pop top of stack
    >            : go right
    D            : D points IP in a random direction
    if D goes left or right it hits > or < respectively and re-enters the random phase
    if D goes down:
     W;          : jump left, pop top of stack
     S-          : push 32 (space) and subtract (convert to uppercase)
     >^          : ip directions to enter the output step
    if D goes up:
     ;           : pop top of stack
     '.;         : push . (46) then pop it immediately, then enter the output step
output:
 o.....;.        : output top of stack as char code and then goto beginning of program.

APL NARS 81 77 54 characters
{1<⍴⍴⍵:¯1⋄⍬≡0↑⍵:¯1⋄⍵≡'':⍵⋄{26<c←⎕a⍳⍵:⍵⋄1=?2:c⌷⎕A⋄⍵}¨⍵}

This can run only in NARS, because it has defined both alphabet array ⎕A for 'A..Z' and ⎕a for 'a..z'. It is 90% sure I wrote something wrong because it is the 4 or 5th function I write in APL; if you note some error please report. I like this language, a little too much path idiomatic. Comments:
h←{1<⍴⍴⍵:¯1⋄⍬≡0↑⍵:¯1⋄⍵≡'':⍵⋄{26<c←⎕a⍳⍵:⍵⋄1=?2:c⌷⎕A⋄⍵}¨⍵}

h←          assign to name h its function, h return -1 for error
{1<⍴⍴⍵:¯1   if the argument ⍵ of h is  matrix or tensor return -1
 ⍬≡0↑⍵:¯1   if the argument ⍵ of h is a scalar numeric or vector numeric return -1
 ⍵≡'':⍵     if the argument ⍵ of h is the void string '' return it
  {   define one anonimous function in h with argument ⍵
        find in the vector ⎕a=a..z the index char ⍵, assign it to c
   26<c←⎕a⍳⍵:⍵
        if that index not exist [in this case must be c=27]return unchanged ⍵
   1=?2:c⌷⎕A
        now index is in 1..26, ⍵ is in a..z; if rand() in 1..2 is 1, return ⎕A[c] where ⎕A is A..Z
   ⋄⍵   else return the argument unchanged
¨⍵}         for each character argument ⍵ of h, apply anonimous function
            for build the result string and return it

results
  h
SYNTAX ERROR
  h
  ∧
  h 1
¯1
  h 1.23
¯1
  h 1 2 3
¯1
  h 2 3⍴1 2 3
¯1
  h ''

  h ' '

  h '  '

  h 'Hello World'
HElLo WOrlD
  h 'Hello World'
HELlo WoRlD
  h 'Hello World'
HELlO WoRLD
  h 'Hello World'
HeLLO WOrld
  h 'Hello World'
HEllO WORld

these it seems are  scalars chars and some vector
  h 'a'
A
  h 'a'
a
  h 'a'
a
  h 'a'
a
  h ,'a'
A
  h ,'a'
A
  h ,'a'
a
  h ,''

Woah, NARS allows you to do something like 98..123?

@Zacharý yes it seems one can use range interval

Julia, 56 bytes
f(s)=join(map(x->(rand(Bool)?uppercase:lowercase)(x),s))

Try it online!

Bash, 65
while IFS= read -N1 L;do((RANDOM%2))&&L="${L^}";echo -n "$L";done
Example:
while IFS= read -N1 L;do((RANDOM%2))&&L="${L^}";echo -n "$L";done<<<"Word string with spaces! and symbols if Desired."
>
WoRD stRINg WITh SPacEs! AND SymbOlS IF DESiRed.

><>, 37 bytes
i:0(?;::84*\{?$~-o
+){$({"za" /0~x<0}

Try it online!
This program works by randomly selecting either 32 or 0, which will only be subtracted from the value of the letter if is in the range [a-z].
The program mostly linear, but I have 'folded' it to allow reuse of an $ token. Here it is unfolded:
i:0(?;::84*"az"{(${)+}0>x~0{?$~-o
                        $

The x token causes the instruction pointer to move in one of the four cardinal directions, chosen at random. When the IP reaches the x token, the top of the stack has 0 and 32 on it. If the IP moves left, it hits a > which immediately returns the IP to the x. If it moves up or down, it hits the $, which swaps the 0 and 32 around, then returns to the x. If it moves right, it hits the ~, discarding the value on the top of the stack and continuing with program execution.
To save on lots of wasted characters, the program is split, the middle flipped, and a reflector put inbetween:
i:0(?;::84*"az"{(${)+}0>x~0{?$~-o

i:0(?;::84*                {?$~-o
           "az"{(${)+}0>x~0

i:0(?;::84*                {?$~-o
           +){$({"za"0~x<0}

i:0(?;::84*\{?$~-o
+){$({"za" /0~x<0}

This puts a $ directly above the x, recreating the program flow as described in the unfolded version.

F#, 104 bytes
open System
let r=Random()
let f=Seq.fold(fun a x->a+string(if r.Next 4=0 then Char.ToUpper x else x))""

Try it online!
Pretty straight-forward. Start with an empty string, then keep adding characters to it. Each character has a 1-in-4 chance of being capitalised.
I'm pretty sure I can get it under 100 bytes, but I can't see how...

Prolog (SWI), 65 bytes
[H|T]-[I|U]:-T-U,(H>97,H<123,random(0,2,1),I is H-32;I=H).
[]-[].

Try it online!

Common Lisp, 112 91 bytes
(defun f(s)(map'string(lambda(c)(if(>(random 2(make-random-state t))0)(char-upcase c)c))s))

Try it online!
:| Lisp's random isn't seeded by default

Gaia, 6 bytes
⌉,†ṛ¦$

Try it online!
Explanation
⌉       Uppercase the string
 ,†     Vectorize pair the uppercase with the original string (creates pairs of corresponding chars)
   ṛ¦   Randomly choose one character from each pair
     $  Join
        Implicit output

Factor, 33 bytes
[ [ .5 [ ch>upper ] whenp ] map ]

Try it online!

[ ... ] map Transform each character in the input string using a quotation.
.5 [ ch>upper ] whenp Call ch>upper with probability 0.5. ch>upper capitalizes a code point.

Lua, 83 bytes
print((io.read():gsub(".",function(x)return.5>math.random()and x:upper()or x end)))

Try it online!

Thunno 2 J, 4 bytes
RZ€ɼ

Attempt This Online!
Port of totallyhuman's Jelly answer.
Explanation
RZ€ɼ  # Implicit input  ->  "Hello World"
R     # Uppercase       ->  "HELLO WORLD"
 Z    # Zip with input  ->  ["HH","eE","lL","lL","oO","  ","WW","oO","rR","lL","dD"]
  €   # To each pair:
   ɼ  #  Random choice
      # Implicit output, joined

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Jolly gerrymandering
Background
The United States has a unique love of gerrymandering––the deliberate manipulation of an electoral district to predict certain voting results. Just recently there was a gerrymandering case brought before the Supreme Court. Gerrymandering, especially when related to race, is ruled illegal and results in the requirement to redraw the district lines.
Given a rectangular map of a municipality (2d array), you will draw district lines to help your party get the most representation. That is, you will gerrymander. Every municipality has two parties, 0 and 1. The map will be comprised of squares with either 0 or 1 on them. Here is an example map:

Challenge
You will group the map into districts so that the 1 party will get at least the number of districts specified by the Input.
Input
The input will consist of a map, the number of districts to draw, and the minimum number of districts the 1 party needs to win (the minimum score).
Output
The output will be a map of the districts. Each district will be uniquely comprised of a capitalized letter of the alphabet. Yes, this means that there will not be more than 26 districts.
If there is no possible output where the inputted party wins enough districts, either:

Print “We tried...”
Fatally error because the party was irreparably injured by the  election results
Or both

Rules (also very important)

All districts must be contiguous
Districts may not have other districts in them
Each district must have at least four nodes in it. The input will be consistent with the rules, meaning that there will be at least number_of_districts * 4 nodes in the map
The score of each party is the number of districts it has a majority in
If a district has the same number of 0s and 1s, then neither party benefits from it
Normal no-cheating rules
This is code-golf, so shortest code in bytes wins.

Test cases
1. Input       1. Output       2. Input       2. Output     3. Input      3. Output
districts: 5   Image and map   districts: 3   Image below   districts: 3  fatal error
min wins: 3                    min wins: 3                  min wins: 3
map:                           map:                         map:
00000110000    AAAAAAAAAAA     101101                       101101
10000010000    AAAAAAAAAAA     100000                       100000
10010000011    AAAAAAAAAAA     011011                       011011
11001110000    BBBBBBBAAAA     111111                       100111
00111111000    BBBBBBBAAAA
01111111000    CCCCCDDDAAA
01111111001    CCCCCDDDAAA
01000111100    EEEEEDDDDDD
00000001000    EEEEEDDDDDD

Of course, your program should work for any valid test case, not just these ones.

@Arnauld, yes they are only illustrative. The real output should be like in the first test case with the letters of the alphabet. I changed the tag to reflect this.

A simple partition of the first test case would be something like this. Is that correct?

@Arnauld, yes, that's valid.

So for the 3rd example, if we divided it into horizontal rows, each 1 district tall, then the 1s would win 3 to 1 yes?

@MichaelDorgan, yes, except that you may only have three districts in that one.

Ah - hence the fail.  Missed the district count.  Thanks

This reminds me a whole lot of what had to be done for char based graphics on Nintendo handhelds from DMG up to DS.  You were given specific shapes to cut graphics into and had to minimize the number of shapes used as you could only have a hardware defined number of sprites (shapes) in use.  That was not an easy problem.

I think this problem may be more suitable for fastest-code?

interesting, tough problem.  is there an efficient algorithm for this?  what is its complexity?

"districts must not have other districts within them" means that something like AAA ABA AAA wouldn't be allowed, right?

@Giuseppe, exactly

What is the format of the 'map'? String with newlines? Sequence of strings? 2D Array of booleans?

@Ourous, any of those works.

R, 938 896 858 952 bytes
function(N,M,m){U="We tried...
"
L=length
A=matrix
W=which
K=sum
S=sample
G=unique
H=function(s,p=s-1){Y=S(c(s-j,s+j,p*(p%%j>0),(s+1)*(s%%j>0)))
Y[Y>0&Y<=k]}
C=function(v,z=W(r==v))K(z%%j<2,z-j<0,(z+j)>k)
m=A(strsplit(m,"")[[1]],1)
i=W(m<0)[1]-1
m=((t(A(m,i+1))[,1:i]>0)-.5)*2
if((K(m)<M&(N-M)<1)|K(m>0)<(3*M))cat(U) else{j=max(1,nrow(m))
k=i*j;w=g=T
while(w<9&g){Z=R=N;Q=M;b=0
r=A(0,j,i)
while(b<9&g){s=W(r<1)
s=s[S(L(s))][1:min(L(s),R)]
r[s]=1:L(s);a=0
while(K(r<1)>0&a<(k^2)){a=a+1
s=S(W(r>0&r<=R),1);p=r[s]
Y=H(s)
Y=Y[r[Y]<1]
if(L(Y)){Y=Y[order(m[Y])]
if(K(m[r==p]>1))r[Y[1]]=p else r[Y[L(Y)]]=p}}
if(a<(k^2)){for(v in 1:R){if(K(m[r==v])>0){r[r==v]=max(k,max(r))+1
Q=Q-1;Z=Z-1}}
if(Q<1){g=F
for(v in 1:R)r[r==v]=max(k,max(r))+1
for(v in G(c(r)))g=g|(K(r==v)<4)|(L(G(r[H(W(r==v))]))+C(v))<3}}
b=b+1;r[r<=R]=0;R=Z}
w=w+1}
if(g)cat(U) else{u=G(c(r))
for(v in 1:L(u))r[r==u[v]]=v
cat(paste(apply(A(LETTERS[r],j,i),1,paste,collapse=""),collapse="
"))}}}

Try it online!
A massive >900 >800 (nope!) >900 bytes solution.
The code works as follows. Let N be the number of electoral districts and M the minimum number of district where 1 wishes to have a majority.
First, the code randomly assigns N districts to different groups. Next, it randomly expands them, i.e. adds a district to a randomly selected group, ensuring that the district is next to a district already belonging to that group. In the expansion process, it gives precedence to a district with a 1 majority, if the district group is not yet a full 1 majority; if the group is already a certain 1 majority, then it gives precedence to a 0 district. It continues until all districts have been assigned.
Every group where there is a majority for the 1 party is stored, and its districts are locked. If there are at least M groups with a majority of 1, then everything is good and we can print the result we can check whether there are at least 4 districts in each group. If the cutoff of 4 districts is met, then we can happily print the result. Otherwise, the code tries to reassign the districts that are not locked to as many groups as available, i.e. N - #stored-groups.
The codes tries a few times (9 times). If it fails, it resets everything and starts again. It does so for other 9 times before giving up and printing "we tried...".
If the code does not succeed at first, try again a few times. I tuned the number of repetitions such that it can run in TIO under a minute. However if there is a solution, this code can (eventually) find it. The randomness part of the algorithm gives a non-zero probability that, if there is a solution, it can find it. The limited number of trials is the only limiting factor to success.
EDIT: added the control that no district group can be fully surrounded by just another one, unless the district group has districts on the edge of the given square. I think I missed it at first.

Can you remove any newlines?

I did. I also assigned longer function names to single letters, and replaced a few ==0 with <1 when the variable was strictly integer and positive.

There's a lot of stuff here that can be trivially golfed but this is a good first attempt at an answer, so +1, and I'll be suggesting edits I a couple hours once I'm not on my phone!

858 bytes -- "regular" golfs, cleaning up the use of braces with if...else statements, swapping c for as.vector, changing "\n" with literal newlines, and using the fact that > will automatically coerce numbers to characters silently and compare their codepoints. There's probably some other golfs I did that I can't remember but this is a start. I think there are a few more things we can tweak down but I'm not 100% sure I understand the code...

Nice one! I took inspiration. By comparing to your code I also found a bug in mine that would sometimes lead to very small district groups (less than 4 districts). It is now fixed.

Would this program usually work but not necessarily always because of the randomness and trying only at most 81 times?

Yes, the number of trials could be increased at the cost of some bytes but then it may time out on tio. --edit: I think I missed checking that a group is not fully surrounded by another group. I'll add that shortly. Sorry!

Python3, 1067 bytes:
E=enumerate
R=range
def P(b):
 c=[(x,y)for x,r in E(b)for y,_ in E(r)]
 while c:
  C=c.pop(0)
  q,s=[C],[C]
  while q:
   x,y=q.pop(0)
   for X,Y in[(0,1),(0,-1),(-1,0),(1,0)]:
    T=(x+X,y+Y)
    if T in c and T not in s and b[x+X][y+Y]==b[x][y]:q+=[T];s+=[T]
  yield s;c=[*{*c}-{*s}]
def S(b,g):
 k=[0,0]
 for x,y in g:k[b[x][y]]+=1
 return k[1]>k[0]
def F(n,m,b):
 B=eval(str(b))
 for G in P(B):
  if len(G)<4:
   for x,y in G:B[x][y]=int(not B[x][y])
 q=[(B,L:=[*P(B)],sum(S(b,i)for i in L))]
 H=[L]
 while 1:
  B,G,C=q.pop(0)
  O=max(j for k in B for j in k)+1
  if len(G)==n and sum(S(b,i)for i in G)>=m:
   for Y,i in E(G,65):
    for x,y in i:B[x][y]=chr(Y)
   return B
  for x in R(len(b)+1):
   for y in R(len(b[0])+1):
    for X in R(x+1,len(b)+1):
     for Y in R(y+1,len(b[0])+1):
      if(X-x)*(Y-y)>=4 and S(b,T:=[(j,k)for j in R(x,X)for k in R(y,Y)]):
       Q=eval(str(B))
       for U,I in T:Q[U][I]=O
       if len(W:=[*P(Q)])<=n and len(W)>=len(G)and W not in H and all(len(i)>=4 for i in W)and(N_C:=sum(S(b,i)for i in W))>=C:q+=[(Q,W,N_C)];H+=[W]

Try it online!
Notes:

A little longer than the other solution, but deterministic and runs in ~3.65 seconds
Fatally-errors if there is no possible output

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
In which number set do I belong?
Introduction
Mathematicians often work with number sets. These are groups of numbers that share common properties. These are number sets are, in order from most specific to most broad:
Natural numbers   (symbol N): These are the counting numbers: 1, 2, 3, ...
Integers          (symbol Z): These are all the numbers without a fractional part: ..., -3, -2, -1, 0, 1, 2, 3, ...
Rational numbers  (symbol Q): These numbers are the quotients of two integers, such as: 1.1 (11/10), 5.67 (567/100), or 0.333333333... (1/3)
-----The following two numbers sets are equally specific in describing numbers-----
Real numbers      (symbol R): These are positive, zero, and negative numbers, such as: π (3.1415926...), e (2.7182818...), or √2 (1.4142135...)
Imaginary numbers (symbol I): Numbers that give negative values when squared; for this reason they aren't very useful in everyday life.
                              These numbers contain the letter i in them, with i representing the √-1.
                              Examples: 2i, -1.5i 78i, 9i, -3.1415i, i
-----------------------------------------------------------------------------------
Complex numbers   (symbol C): The sum of a real and an imaginary number in the form a + bi, examples: 2 + 7i, 3 + 3i, 1 - i, -8 + i

Note that when there is only a single i, it is not written 1i.
Challenge
Given a number from one of these number sets, print the symbol for the most specific number set that could describe it.
Test cases
Input              Output
73.0            -> N
4/2             -> N
-73             -> Z
-1/3            -> Q
0.56            -> Q
0.555...        -> Q
0.123123123...  -> Q
3.1415926535... -> R
-1.37i          -> I
7892/5 + 23/4i  -> C

Other info

Natural numbers and integers may be given with a decimal point followed by a string of zeros
To add on to the previous point, any input that can be converted into a simpler form shall have its output corresponding to the simplified input
Rational numbers may be given with a / to represent a fraction, or a sequence of numbers occurring 3 or more times followed by ...
Numbers ending with ... represent repeated decimals or un-terminated decimal real numbers
Any number sets less specific than Q can also have inputs be given as a fraction
You do not need to handle repeated decimals or un-terminated decimals for number sets other than Q and R
Any error caused by lack of precision in floating point numbers will not invalidate a submission

This is code golf, so shortest code wins. If there is something unclear, let me know in the comments' section or edit the question.

I don't see how one could distinguish Q and R given the limited precision of machine numbers.

More fundamentally, it's not clear to me whether the inputs are number types in our languages, or strings of them. How much control do we have for how an input is given, in a language where, say, 0 can be represented as one of multiple number types? For example, when you say that inputs can be given as a fraction, do you mean that we have to handle inputs that might possibly be fractions, or this is a choice you can opt for? I think there's a lot of subtlety in specifying this challenge and suggest taking it the Sandbox.

What's the output of -3/3?

@xnor When I wrote "may", I meant that there exists a possibility. Should I clarify that?

@LuisMendo Very good point but I think you could have expanded. Indeed there are many machines employing only floating point that would say -3/3 = -0.999.. or possibly even 1.000...1. That's why many languages have different operators for integer and noninteger division, so the programmer gets to decide.

@LuisMendo@LevelRiverSt, I hope I have addressed that fact.

@xnor I hope the last bullet point addresses that.

@ericw31415 What I think xnor meant is: can we write the program and state "rationals are input with a /"? Or must the program be able to handle both 1/2 and 0.5 as input?

@ericw31415 I don't understand it. It seems like it allows treating R and Q interchangeably -- is that what you mean? And I'm even more confused now with "expression of possibility" vs "permission".

@xnor I was trying to say that such an input was possible. For some reason I can't seem to word it correctly though.

@xnor 3 repeats of a sequence of digits before the ... seems to be the distinguishing factor between them

such an input was possible Again, possible as in you can choose to use it, or as in you need to support it?

Suggested test case: 4/2 -> N (my initial answer wasn't passing that one; now fixed)

I is irrational number set...

@user202729 Where'd you see that?

Here.

@user202729 From here, I get I is imaginary, and from here I get I is integers.

@LuisMendo I think users can use their judgment as clearly, the first test case and all the ones containing / would fail if they were not supported.

JavaScript (ES6), 121 110 bytes
s=>[...'QRCI'].find((_,i)=>[/(.+)\1\1\.\./,/\.\./,/.+[+-].*i/,/i/][i].test(s))||'QNZ'[k=eval(s),k%1?0:k>0?1:2]

Test cases

let f =

s=>[...'QRCI'].find((_,i)=>[/(.+)\1\1\.\./,/\.\./,/.+[+-].*i/,/i/][i].test(s))||'QNZ'[k=eval(s),k%1?0:k>0?1:2]

console.log(f('73.0'           )) // -> N
console.log(f('4/2'            )) // -> N
console.log(f('-73'            )) // -> Z
console.log(f('-1/3'           )) // -> Q
console.log(f('0.56'           )) // -> Q
console.log(f('0.555...'       )) // -> Q
console.log(f('0.123123123...' )) // -> Q
console.log(f('3.1415926535...')) // -> R
console.log(f('-1.37i'         )) // -> I
console.log(f('7892/5 + 23/4i' )) // -> C

Formatted and commented
s =>                  // given the input string s
  [...'QRCI'].find(   // we first apply some regular expressions:
    (_, i) => [       //   i = index
      /(.+)\1\1\.\./, //     i = 0 (Q): 3x the same pattern, followed by '..' -> rational
      /\.\./,         //     i = 1 (R): '..' without the repeated pattern -> real
      /.+[+-].*i/,    //     i = 2 (C): a real part +/- an imaginary part -> complex
      /i/             //     i = 3 (I): just an imaginary part -> imaginary
    ][i].test(s)      //   this is a find(), so we exit as soon as something matches
  ) || 'QNZ'[         // if all regular expressions failed:
    k = eval(s),      //   assume the expression can now be safely evaluated as JS code
    k % 1 ?           //   if there's a decimal part:
      0               //     -> rational
    :                 //   else:
      k > 0 ?         //     if strictly positive:
        1             //       -> natural
      :               //     else:
        2             //       -> integer
  ]                   //

Very nice! I probably would not have been able to come up with a regex that fast.

Save 1 B using (.+){3} vs. (.+)\1\1

@EphellonDantzler This would match any string of at least 3 characters instead of 3 times the same string.