Ratio of Uppercase Letters to Lowercase
JavaScript (ES6) 87 bytes
Edit 1 byte saved thx ETHProductions
Edit 1 more byte saved thx l4me
An anonymous function. Long, but I didn't find a way to golf this more
s=>(l=t=0,s.replace(/[a-z]/ig,c=>l+=++t&&c>'Z'),l/=t,l<.5?1-l+' upp':l+' low')+'ercase'
Less golfed
s=>( // arrow function returning the value of an expression
// here I use comma for clarity,
// in the golfed version it's all merged in a single expression
t = 0, // counter for letters
l = 0, // counter for lowercase letters
s.replace(
/[a-z]/ig, // find all alphabetic chars, upper or lowercase
c => // execute for each found char (in c)
l += ++t && c>'Z', // increment t, increment l if c is lowercase
),
l /= t, // l is the ratio now
( l < .5 // if ratio < 1/2
? (1-l) +' upp' // uppercase count / total (+" upp")
: l +' low' // lowrcase count / total (+" low")
) + 'ercase' // common suffix
)
CJam, 47 45 bytes
q__eu-\_el-]:,_:+df/" low upp"4/.+:e>"ercase"
Try it online.
Not golfing for too long...
Explanation
q e# Read input.
__eu- e# Get only the lowercase characters.
\_el- e# Get only the uppercase characters.
]:, e# Get the lengths of the two strings.
_:+ e# Sum of the lengths.
df/ e# Lengths divided by the sum of the lengths.
" low upp"4/.+ e# Append the first number with " low" and the second " upp"
:e> e# Find the maximum of the two.
"ercase" e# Output other things.
Japt, 58 bytes
A=Uf"[a-z]" l /Uf"[A-Za-z]" l)>½?A+" low":1-A+" upp" +`ÖÐ
(Note: SE stripped a special char, before Ö
, so please click the link to get the proper code)