# type in a random mess of capital letters [duplicate]

SOMe PEOPle lIkE tO TYpE iN A LoGiCAL MAnNER, WITh CapITals aT tHe bEGiNnIng Of ThE SENtENCE and smaLl LETTErS EVeRYWHErE eLsE. NOT Us. NOt Us. Your joB iS to tAkE A SenTEncE Of A LL SMAlL LeTTeRS, And rANDOmly ChAnGe sOMe to caPiTAl. ThiS iS a Code gOLF so tHE SmaLleST coDE WIll win.

the input will always be small letters and spaces with punctuation only.

random meaning running the code multiple times will always yield different results.

test cases for this will be hard since it involves random elements.

here is a shitty example with python

https://onlinegdb.com/Hy0_gEEKH

• Welcome to CG&CC! This could do with some test cases, and some formal guarantees about the nature of the input. It can't hurt to define random, either. I think I've seen similar challenges, but can't find anything this is a duplicate of. – Unrelated String Oct 16 '19 at 6:11
• The input will be lower case letters only. Does that mean only a-z, or can there be spaces and other characters? Is it enough that the first letter is randomly capitalized, or is it required that all characters can be capitalized? Do you require uniform randomness? – Stewie Griffin Oct 16 '19 at 6:40
• Related: Random Capitalization That challenge differs in the input having already-capital letters which should stay capital. Maybe still a duplicate. – xnor Oct 16 '19 at 6:58
• The "random" specification as it stands is incomplete – Luis Mendo Oct 16 '19 at 7:21
• (changed my mind) I believe this is far too similar to not be considered an exact duplicate of the other challenge, since the dominant strategy (basically the only one used) is to choose between each character and the character uppercased, which, being valid for both challenges, makes answer tactics fundamentally identical. – HyperNeutrino Oct 17 '19 at 19:28

# APL (Dyalog Extended), 6 bytesSBCS

Anonymous tacit prefix function. Assumes ⎕IO←0 (0-based indexing)

⊢×∘?2¨


Try it online!

2¨ number two for each character

? random index among the first that many indices (i.e. 0 or 1 for each character)

∘ then

× use that to change case (0:lower; 1:upper) on the following:

⊢ the unmodified argument

# Python 3, 59 bytes

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


Try it online!

-4 bytes thanks to Chas Brown

Uses set.pop() to randomize.

• 63 bytes. Never knew pop could be used for random choice... nice! – Chas Brown Oct 16 '19 at 22:02
• @ChasBrown good find, thanks! pop picks an item based on hash value. From Python 3.something onward, this is completely randomized for a.o. strings. The catch is that it is only assigned once per string per session, so it can only be used in a full program. – Jitse Oct 17 '19 at 5:46

{,/{c$x-32*1?2*(x<123)*x>96}'x}  Try it online! # Red, 8078 58 bytes func[s][foreach c s[prin do pick[c[uppercase c]]random 2]]  Try it online! # Japt-m, 5 bytes c^HÑö  Try it • the challenge states input will have"small letters and spaces with punctuation", this fails when there are non-letters – Embodiment of Ignorance Oct 17 '19 at 3:14 • @EmbodimentofIgnorance, it was lowercase letters only at time of posting. Would you believe, though, I also had your solution written up in another tab but copied the Markdown from the wrong one?! – Shaggy Oct 17 '19 at 22:09 # Japt-m, 4 bytes +u)ö  Try it -m //Map all characters in input + //Input prepended to u) //Input to uppercase ö //Random character  # Python 2, 72 bytes lambda i:"".join(choice(x)for x in zip(i,i.upper())) from random import*  Try it online! # PowerShell, 6046 43 bytes -3 bytes thanks to mazzy -join($args|%{"$_"|%('t*g','*per'|random)})  Try it online! • perhaps toUpper will be better? – mazzy Oct 17 '19 at 18:59 • @mazzy Yep, it was. Thanks – Veskah Oct 17 '19 at 19:08 • nice. -3 bytes :) – mazzy Oct 18 '19 at 4:28 # Jelly, 5 bytes żŒuX€  Try it online! Stolen from totallyhuman's solution to Random Capitalization. My original solution, since I forgot Jelly has ż: # Jelly, 6 bytes Œu,X¥"  Try it online! ,ŒuXƊ€ works for the same byte count.  " For every element of the input and every corresponding element of Œu the input capitalized, ,X¥ choose one or the other at random.  # Perl 5, 22 bytes s/./.5<rand?uc$&:$&/ge  Try it online! # Charcoal, 8 bytes ⭆Ｓ‽⁺↥ι↧ι  Try it online! Link is to verbose version of code. Trivial modification of my answer to Random Capitalization. # Python 3, 94 bytes s=input();from random import*;print("".join([i.upper() if randint(0,1)==1 else i for i in s]))  Try it online! # C# (Visual C# Interactive Compiler), 59 bytes x=>x.Select(l=>z.Next()<1?l.ToUpper():l);var z=new Random()  Try it online! • 51 bytes - x=>x.Select(l=>new Random().Next()<1?l.ToUpper():l) – Innat3 Oct 17 '19 at 10:12 # C (gcc), 109 46 bytes Thanks to Johan du Toit for -63 bytes f(char*s){for(;*s++-=(*s-97u<26&rand())*32;);}  Try it online! # PHP, 51 50 bytes for(;$l=$argn[$i++];)echo$l>_&&rand()%2?$l^' ':$l;  Try it online! # PHP, 51 50 bytes for(;$l=$argn[$i++];)echo rand()%2?ucfirst($l):$l;
`

Try it online!