Skip to main content
2 of 4
New version; added 91 characters in body; deleted 1 character in body; added 118 characters in body
Business Cat
  • 9.2k
  • 1
  • 17
  • 37

CJam, 21 17 bytes

New version

'[,{,'A,-}%M*mr0=

This forms an array of strings following the pattern A, AB, ABC, and so on. It flattens it and chooses a random character. Since this string contains 26 A's, 25 B's, 24 C's, and so on, each letter has a distinct probability of being chosen.

Try it online!

Explanation

'[,               e# Push the range containing all characters up to 'Z'
   {,'A,-}%       e# For each character, push the range of all characters from it to 'A'. 
                  e# This will be an empty string for any character before 'A'.
           M*     e# Join with no separator
             mr   e# Shuffle the string
               0= e# Get the first character

Old version

26,:)'[,'A,- .*M*mr0=

Gets distinct probabilities by making a string in which each letter appears a number of times equal to its position in the alphabet.

26,:)                 e# Push 1, 2, ... 26
     '[,'A,-          e# Push 'A', 'B', ... 'Z'
             .*       e# Vectorize: repeat each letter the corresponding number of times
               M*     e# Join with no separator
                 mr   e# Shuffle the string
                   0= e# Get the first character
Business Cat
  • 9.2k
  • 1
  • 17
  • 37