| Bytes | Lang | Time | Link |
|---|---|---|---|
| 082 | AWK | 250319T151927Z | xrs |
| 133 | Tcl | 180507T232308Z | sergiol |
| 053 | APLNARS | 250324T193214Z | Rosario |
| 087 | Zsh* | 250324T090823Z | roblogic |
| 040 | Uiua | 250322T160303Z | janMakos |
| 043 | ☾ | 250322T191721Z | Joao-3 |
| 035 | Japt v2.0a0 | 250319T123448Z | Shaggy |
| 118 | C gcc | 180525T223136Z | ceilingc |
| 159 | WDC 65816 machine code | 191022T214829Z | trillian |
| 080 | Javascript | 191022T210211Z | Justin |
| 120 | C | 181229T181454Z | user5898 |
| 132 | Common Lisp | 181229T203004Z | Renzo |
| 087 | JavaScript ES6 | 151225T173357Z | edc65 |
| 116 | APLNARS | 181229T204318Z | user5898 |
| 104 | R | 180508T005728Z | JayCe |
| 128 | PowerShell Core | 180508T164526Z | Jeff Fre |
| 039 | Pyth | 180508T152547Z | user4854 |
| 138 | Kotlin | 180508T174408Z | jrtapsel |
| 072 | Perl 5 p | 180508T170803Z | Xcali |
| 144 | REXX | 180508T112738Z | idrougge |
| 149 | Clojure | 180508T104900Z | NikoNyrh |
| 130 | Java 8 | 180508T071706Z | Kevin Cr |
| 028 | 05AB1E | 180508T013101Z | Magic Oc |
| nan | Ruby | 151229T142739Z | histocra |
| nan | 151228T000741Z | Christal | |
| 110 | Python 2 | 151225T175939Z | TFeld |
| 084 | Candy | 151229T002421Z | Dale Joh |
| 097 | Ruby | 151228T093432Z | manatwor |
| 110 | Matlab | 151227T110623Z | brainkz |
| 058 | Japt | 151225T203053Z | nicael |
| 179 | Pure Bash | 151227T160139Z | F. Hauri |
| nan | 151227T135354Z | ProgramF | |
| 053 | Pyth | 151225T223518Z | RK. |
| 040 | Pyth | 151226T055339Z | Maltysen |
| 104 | CoffeeScript | 151225T212851Z | john dik |
| 045 | Pyth | 151226T022812Z | PurkkaKo |
| 045 | CJam | 151225T173638Z | jimmy230 |
| 058 | Seriously | 151225T235600Z | quintopi |
| 125 | Gema | 151225T181023Z | manatwor |
| 061 | Perl 6 | 151225T225955Z | Brad Gil |
| 074 | Julia | 151225T173419Z | Alex A. |
| 049 | MATL | 151225T175926Z | Luis Men |
| 105 | Mathematica | 151225T173256Z | LegionMa |
AWK, 93 82 bytes
{m=(x=gsub(/[A-Z]/,X))+(y=gsub(/[a-z]/,X))}$0=(x/m>.5?x/m" upp":y/m" low")"ercase"
{printf"%.2f %sercase",((x=gsub(/[A-Z]/,X))>(y=gsub(/[a-z]/,X))?x:y)/(x+y),(x>y?"upp":"low")}
Tcl, 133 bytes
proc C s {list [expr max([set u [regexp -all {[A-Z]} $s]],[set l [regexp -all {[a-z]} $s]])/($u+$l.)] [expr $u>$l?"upp":"low"]ercase}
APL(NARS), 53 chars
∊((⌈/m)÷+/m)((1+</m←+/¨⎕∘∊¨⎕A⎕a)⊃'upp' 'low')'ercase'
test:
∊((⌈/m)÷+/m)((1+</m←+/¨⎕∘∊¨⎕A⎕a)⊃'upp' 'low')'ercase'
⎕:
'PrOgRaMiNgPuZzLeS & CoDe GoLf'
┌10─────────────┐
│ 0.52 uppercase│
└+──────────────┘
∊((⌈/m)÷+/m)((1+</m←+/¨⎕∘∊¨⎕A⎕a)⊃'upp' 'low')'ercase'
⎕:
'Foo BaR Baz'
┌10─────────────────────┐
│ 0.5555555556 lowercase│
└+──────────────────────┘
Zsh*, 87 bytes
*with set -o force_float
u=${#1//[^A-Z]};d=${#1//[^a-z]}
((s=u+d,u>d))&&1=$[u/s]\ upp||1=$[d/s]\ low
<<<$1ercase
☾, 43 chars
ᴍⴵᑀ⨁÷🃌⟞ᐒ‹⟦½⟞⫰+½⟧ ⟦⟞<0⭜"low"⭝"upp"⟧ercase›
This would've been way shorter if I didn't have to format it neatly.
Explanation
Japt v2.0a0, 35 bytes
è\A ÷Uè\l
wUn1)+S+`ÓsrÖÐ ÕèrÖÐ`¸gUr
Try it (includes all test cases)
è\A ÷Uè\l\nwUn1)+S+`...`¸gUr :Implicit input of string U
è :Count the occurrences of
\A : /[A-Z]/g
÷ :Divide by
Uè\l : Count the occurrences of /[A-Za-z]/g in U
\n :Reassign to U
w :Maximum with
Un1 : U subtracted from 1
) :End maximum
+S+ :Append space and
`...` : Compressed string "lowercase uppercase"
¸ : Split on spaces
g : Get element at 0-based index
Ur : U rounded
C (gcc), 124 121 119 118 bytes
u,l;f(char*x){for(u=l=0;*x;x++)isalpha(*x)?*x>96?l++:u++:0;printf("%f %sercase\n",fmax(l,u)/(u+l),u>l?"upp":"low");}
Slightly ungolfed
u,l;
f(char*x){
for(u=l=0;*x;x++)
isalpha(*x)?*x>96?l++:u++:0;
printf("%f %sercase\n",fmax(l,u)/(u+l),u>l?"upp":"low");
}
WDC 65816 machine code, 159 bytes
Hexdump:
00000000: a200 009b 8006 e600 9002 e601 b200 f016 ................
00000010: c941 90f2 c95b b003 e880 ebc9 6190 e7c9 .A...[......a...
00000020: 7bb0 e3c8 80e0 c220 8602 9865 0285 04c4 {...... ...e....
00000030: 0290 0ea9 6c6f 850f a977 6585 1184 0280 ....lo...we.....
00000040: 0aa9 7570 850f a970 6585 11a9 6400 8508 ..up...pe...d...
00000050: 6406 a900 0018 6502 c504 9006 e504 e606 d.....e.........
00000060: 80f6 c608 d0ef 0ac5 0490 02e6 06a9 302e ..............0.
00000070: 850a a900 2085 0da9 7263 8513 a961 7385 .... ...rc...as.
00000080: 15a9 6500 8517 a230 00a5 06c9 0a00 9006 ..e....0........
00000090: e90a 00e8 80f5 e230 6930 850d 860c 60 .......0i0....`
Assembly:
; pointer to null-terminated string is in $00-$01
; enter in 8-bit accumulator mode (SEP #$20), 16-bit index mode (REP #$10)
; output is a null-terminated string starting at $0A, ends at $18
count:
; X - number of uppercase chars
; Y - number of lowercase chars
LDX #$0000
TXY
BRA .firstiter
.loop:
INC $00
BCC .firstiter
INC $01
.firstiter:
LDA ($00)
BEQ calc_maj
CMP #$41 ; 'A'
BCC .loop
CMP #$5B ; 'Z'+1
BCS +
INX
BRA .loop
+ CMP #$61 ; 'a'
BCC .loop
CMP #$7B ; 'z'+1
BCS .loop
INY
BRA .loop
calc_maj:
; okay, now the hard part
; $02 is amount of lowercase
; $04 is total
REP #$20
STX $02
TYA
ADC $02
STA $04
CPY $02
BCC +
; Y > X thus more lowercase
LDA #$6F6C ; 'lo'
STA $0A+5
LDA #$6577 ; 'we'
STA $0A+7
STY $02
BRA ++
+ ; Y < X => more uppercase
LDA #$7075 ; 'up'
STA $0A+5
LDA #$6570 ; 'pe'
STA $0A+7
++ ; now $02 is the amount of larger and the buffer's upper/lower word is already initialized
LDA.w #100
STA $08
STZ $06
LDA #$0000
.divmul_outer:
CLC : ADC $02
.divmul_inner:
CMP $04
BCC +
SBC $04
INC $06
BRA .divmul_inner
+ DEC $08
BNE .divmul_outer
; if tmp * 2 >= $04: inc $06
ASL
CMP $04
BCC +
INC $06
+ ; $6 now contains $02 * #100 / $04
; let's write all the other letters while we're still in 16bit mode
; 0.XX XXXXrcase\0
LDA #$2E30 ; "0."
STA $0A
LDA #$2000 ; "\0 "
STA $0A+3
LDA #$6372 ; "rc"
STA $0A+9
LDA #$7361 ; "as"
STA $0A+11
LDA #$0065 ; "e\0"
STA $0A+13
LDX #$0030
LDA $06
- CMP #$000A
BCC +
SBC #$000A
INX
BRA -
+ SEP #$30
ADC #$30
STA $0A+3
STX $0A+2
RTS
(assembled with Asar. The +/- things are labels.)
Input: A 16-bit pointer to the string to count, null terminated. Output: A null-terminated string starting at $0A (and ending at $18). Enter in 8-bit accumulator, 16-bit index mode. (SEP #$20 REP #$10)
God I hate this CPU. Will optimize tomorrow maybe.
Javascript 80 characters
I'm bad at this but here was my go at Javascript:
a=(s)=>{let a=0,b=0;for(c in s)s[c]==s[c].toUpperCase()?a++:b++;return a/(a+b);}
Readable version:
a=(s)=>{
let a=0,b=0;
for(c in s)
s[c]==s[c].toUpperCase()?a++:b++;
return a/(a+b);
}
Function is called with: a('hEllO') which outputs 0.4 for example.
I feel like there must be a way to condense the arrow function or something with the words return or toUpperCase that I can do.
C, 120 bytes
f(char*a){int m=0,k=0,c;for(;isalpha(c=*a++)?c&32?++k:++m:c;);printf("%f %sercase",(m>k?m:k)/(m+k+.0),m>k?"upp":"low");}
test and result:
main()
{char *p="PrOgRaMiNgPuZzLeS & CoDe GoLf", *q="DowNGoAT RiGHtGoAt LeFTGoat UpGoAT", *m="Foo BaR Baz";
f(p);printf("\n");f(q);printf("\n");f(m);printf("\n");
}
results
0.520000 uppercase
0.580645 uppercase
0.555556 lowercase
It suppose Ascii character set.
Common Lisp, 132 bytes
(setq s(read-line)f(/(count-if'upper-case-p s)(count-if'alpha-char-p s)))(format t"~f ~aercase"(max f(- 1 f))(if(> f .5)"upp""low"))
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
)
APL(NARS), 58 char, 116 bytes
{m←+/⍵∊⎕A⋄n←+/⍵∊⎕a⋄∊((n⌈m)÷m+n),{m>n:'upp'⋄'low'}'ercase'}
test:
h←{m←+/⍵∊⎕A⋄n←+/⍵∊⎕a⋄∊((n⌈m)÷m+n),{m>n:'upp'⋄'low'}'ercase'}
h "PrOgRaMiNgPuZzLeS & CoDe GoLf"
0.52 uppercase
h "DowNGoAT RiGHtGoAt LeFTGoat UpGoAT"
0.5806451613 uppercase
h "Foo BaR Baz"
0.5555555556 lowercase
R, 133 123 118 108 106 105 104 bytes
Golfed down 10 bytes thanks to @ovs,8 thanks to @Giuseppe, and 10 again thanks to @ngm. At this point it's really a collaborative effort where I provide the bytes and others take them off ;)
function(x)cat(max(U<-mean(utf8ToInt(gsub('[^a-zA-Z]',"",x))<91),1-U),c("lowercase","uppercase")[1+2*U])
PowerShell Core, 134128 bytes
Filter F{$p=($_-creplace"[^A-Z]",'').Length/($_-replace"[^a-z]",'').Length;$l=1-$p;(.({"$p upp"},{"$l low"})[$p-lt$l])+"ercase"}
Thanks, Veskah, for saving six bytes by converting the function to a filter!
Pyth, 40 39 bytes
Jml@dQrBG1+jdeS.T,cRsJJc2."kw""ercase
Explanation
Jml@dQrBG1+jdeS.T,cRsJJc2."kw""ercase
m rBG1 For the lower and uppercase alphabet...
l@dQ ... count the occurrences in the input.
J cRsJJ Convert to frequencies.
.T, c2."kw" Pair each with the appropriate case.
eS Get the more frequent.
+jd "ercase Stick it all together.
Kotlin, 138 bytes
Code
let{var u=0.0
var l=0.0
forEach{when{it.isUpperCase()->u++
it.isLowerCase()->l++}}
"${maxOf(u,l)/(u+l)} ${if(u>l)"upp" else "low"}ercase"}
Usage
fun String.y():String =let{var u=0.0
var l=0.0
forEach{when{it.isUpperCase()->u++
it.isLowerCase()->l++}}
"${maxOf(u,l)/(u+l)} ${if(u>l)"upp" else "low"}ercase"}
fun main(args: Array<String>) {
println("PrOgRaMiNgPuZzLeS & CoDe GoLf".y())
println("DowNGoAT RiGHtGoAt LeFTGoat UpGoAT".y())
println("Foo BaR Baz".y())
}
Perl 5 -p, 72 bytes
$_=(($u=y/A-Z//)>($l=y/a-z//)?$u:$l)/($u+$l).$".($u>$l?upp:low).'ercase'
REXX, 144 bytes
a=arg(1)
l=n(upper(a))
u=n(lower(a))
c.0='upp';c.1='low'
d=u<l
say 1/((u+l)/max(u,l)) c.d'ercase'
n:return length(space(translate(a,,arg(1)),0))
Clojure, 149 bytes
#(let[C(for[c(re-seq #"[a-zA-Z]"%)](pos?(compare"["c)))[k v](last(sort-by val(frequencies C)))](str(float(/ v(count C)))" "(if k"upp""low")"ercase"))
Java 8, 136 130 bytes
s->{float l=s.replaceAll("[^a-z]","").length();l/=l+s.replaceAll("[^A-Z]","").length();return(l<.5?1-l+" upp":l+" low")+"ercase";}
-6 bytes creating a port of @ProgramFOX' C# .NET answer.
Explanation:
s->{ // Method with String as both parameter and return-type
float l=s.replaceAll("[^a-z]","").length();
// Amount of lowercase
l/=l+s.replaceAll("[^A-Z]","").length();
// Lowercase compared to total amount of letters
return(l<.5? // If this is below 0.5:
1-l+" upp" // Return `1-l`, and append " upp"
: // Else:
l+" low") // Return `l`, and append " low"
+"ercase";} // And append "ercase"
05AB1E, 28 bytes
ʒ.u}gság/Dò©_αð„Œ„›…#'ƒß«®èJ
ʒ.u}g # filter all but uppercase letters, get length.
ság/ # Differential between uppercase and input length.
Dò© # Round up store result in register w/o pop.
_α # Negated, absolute difference.
ð # Push space.
„Œ„›… # Push "upper lower"
# # Split on space.
'ƒß« # Concat "case" resulting in [uppercase,lowercase]
®èJ # Bring it all together.
Ruby, 81+1=82
With flag -p,
$_=["#{r=$_.count(a='a-z').fdiv$_.count(a+'A-Z')} low","#{1-r} upp"].max+'ercase'
It's lucky that for numbers between 0 and 1, lexicographic sorting is the same as numeric sorting.
PHP, 140 129 characters
My first round of golf -- not too bad for a 'standard' language, eh? :-)
Original:
function f($s){$a=count_chars($s);for($i=65;$i<91;$i++){$u+=$a[$i];$l+=$a[$i+32];}return max($u,$l)/($u+$l).($u<$l?' low':' upp').'ercase';}
Shortened to 129 characters thanks to @manatwork:
function f($s){$a=count_chars($s);for(;$i<26;$u+=$a[$i+++65])$l+=$a[$i+97];return max($u,$l)/($u+$l).' '.($u<$l?low:upp).ercase;}
With comments:
function uclcratio($s)
{
// Get info about string, see http://php.net/manual/de/function.count-chars.php
$array = count_chars($s);
// Loop through A to Z
for ($i = 65; $i < 91; $i++) // <91 rather than <=90 to save a byte
{
// Add up occurrences of uppercase letters (ASCII 65-90)
$uppercount += $array[$i];
// Same with lowercase (ASCII 97-122)
$lowercount += $array[$i+32];
}
// Compose output
// Ratio is max over sum
return max($uppercount, $lowercount) / ($uppercount + $lowercount)
// in favour of which, equality not possible per challenge definition
. ($uppercount < $lowercount ? ' low' : ' upp') . 'ercase';
}
Python 2, 114 110 bytes
i=input()
n=1.*sum('@'<c<'['for c in i)/sum(c.isalpha()for c in i)
print max(n,1-n),'ulpopw'[n<.5::2]+'ercase'
Candy, 62 84 bytes
The legit answer is:
b0a(~x#97<{0|1}~y#32*XW-#65-=xX0#27w{ibY+})bZ/="ercase"A12/<{1A-p"upp"|Ap"low"}(;)N;
But adding a range operator and literal characters to Candy, it gets shorter:
(~`a`zw{i}A`A`Zw{v})"ercase"YZY+/~12/>{Ap"upp"|1A-p"low"}(;)N;
Long form as:
while
peekA
"a" "z" between
if
incrZ
endif
pushA
"A" "Z" between
if
incrY
endif
endwhile
"ercase"
pushY
pushZ pushY add
div
peekA
digit1 digit2 div
greater
if
pushA print
"upp"
else
digit1 pushA sub print
"low"
endif
while
printChr
endwhile
digit10 printChr # linefeed
Ruby, 97 characters
->s{'%f %sercase'%[(l,u=[/[a-z]/,/[A-Z]/].map{|r|s.scan(r).size}).max.fdiv(l+u),l>u ?:low: :upp]}
Sample run:
2.1.5 :001 > ['PrOgRaMiNgPuZzLeS & CoDe GoLf', 'DowNGoAT RiGHtGoAt LeFTGoat UpGoAT', 'Foo BaR Baz'].map{|s|->s{'%f %sercase'%[(l,u=[/[a-z]/,/[A-Z]/].map{|r|s.scan(r).size}).max.fdiv(l+u),l>u ?:low: :upp]}[s]}
=> ["0.520000 uppercase", "0.580645 uppercase", "0.555556 lowercase"]
Matlab, 110 bytes
Solution
i=input('','s');a=sum(i>64&i<91);b=sum(i>96&i<123);d=a>b;disp([num2str(max(a,b)/(a+b)),' upp'*d+' low'*~d,'ercase'])
Test:
i='PrOgRaMiNgPuZzLeS & CoDe GoLf';
0.52 uppercase
i='DowNGoAT RiGHtGoAt LeFTGoat UpGoAT';
0.58065 uppercase
i='Foo BaR Baz'
0.55556 lowercase
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)
Pure Bash, 183 185 182 179 bytes
+2 +4 bytes for more golfing.
(Second linebreak is there only to avoid scrollbar, so not counted).
o=({upp,low}ercase) q=;eval s+={A..Z};b="${1//[$s]}";eval s+={a..z}
c="${1//[$s]}";b=$[(${#1}-${#b})*64#fE/(${#1}-${#c})];((b<40#ck))&&
q=1 b=$[41#og-b];printf "%.2f ${o[q]}\n" .$b
Sample:
(set -- "Foo BaR Baz";o=({upp,low}ercase) q=;eval s+={A..Z};b="${1//[$s]}"
eval s+={a..z};c="${1//[$s]}";b=$[(${#1}-${#b})*64#fE/(${#1}-${#c})];((b<
40#ck))&&q=1 b=$[41#og-b];printf "%.2f ${o[q]}\n" .$b)
0.56 lowercase
or
ulRatio() { local b c s o=({upp,low}ercase) q=;eval s+={A..Z};b="${1//[$s]}"
eval s+={a..z};c="${1//[$s]}";b=$[(${#1}-${#b})*64#fE/(${#1}-${#c})];((b<40\
#ck))&&q=1 b=$[41#og-b];printf "%.2f ${o[q]}\n" .$b;}
for string in "PrOgRaMiNgPuZzLeS & CoDe GoLf" \
"DowNGoAT RiGHtGoAt LeFTGoat UpGoAT" "Foo BaR Baz" ;do
echo -e "\\n$string"
ulRatio "$string"
done
PrOgRaMiNgPuZzLeS & CoDe GoLf
0.52 uppercase
DowNGoAT RiGHtGoAt LeFTGoat UpGoAT
0.58 uppercase
Foo BaR Baz
0.56 lowercase
C#, 135 bytes
Requires:
using System.Linq;
Actual function:
string U(string s){var c=s.Count(char.IsUpper)*1F/s.Count(char.IsLetter);return(c>0.5?c+" upp":1-c+" low")+"ercase";}
With explanation:
string U(string s)
{
var c = s.Count(char.IsUpper) // count uppercase letters
* 1F // make it a float (less bytes than (float) cast)
/ s.Count(char.IsLetter); // divide it by the total count of letters
return (c > 0.5
? c + " upp" // if ratio is greater than 0.5, the result is "<ratio> upp"
: 1 - c + " low") // otherwise, "<ratio> low"
+ "ercase"; // add "ercase" to the output string
}
Pyth, 54 53
One byte saved thanks to @Maltysen
K0VzI}NG=hZ)I}NrG1=hK;ceS,ZK+ZK+?>ZK"low""upp""ercase
K0 " Set K to 0
" (Implicit: Set Z to 0)
Vz " For all characters (V) in input (z):
I}NG " If the character (N) is in (}) the lowercase alphabet (G):
=hZ " Increment (=h) Z
) " End statement
I}NrG1 " If the character is in the uppercase alphabet (rG1):
=hK " Increment K
; " End all unclosed statements/loops
c " (Implicit print) The division of
e " the last element of
S,ZK " the sorted (S) list of Z and K (this returns the max value)
+ZK " by the sum of Z and K
+ " (Implicit print) The concatenation of
?>ZK"low""upp" " "low" if Z > K, else "upp"
"ercase" " and the string "ercase".
Pyth - 40 bytes
This is the first time i've ever used vectorized string formatting which is pretty cool.
Kml-zrzd2eS%Vm+cdsK" %sercase"Kc"upp low
CoffeeScript, 104 characters
(a)->(r=1.0*a.replace(/\W|[A-Z]/g,'').length/a.length)&&"#{(r>.5&&(r+' low')||(1-r+' upp'))+'ercase'}"
coffeescript was initially trying to pass the intended return value as an argument to the "r" value, which failed and was super annoying because r was a number, not a function. I got around it by placing an && between the statements to separate them.
Pyth, 45 bytes
AeSK.e,s/LzbkrBG1s[cGshMKd?H"upp""low""ercase
Explanation
rBG1 pair of alphabet, uppercase alphabet
.e map k, b over enumerate of that:
, pair of
b lowercase or uppercase alphabet
/Lz counts of these characters in input
s sum of that
and
k 0 for lowercase, 1 for uppercase
K save result in K
eS sort the pairs & take the larger one
A save the number of letters in and the 0 or 1 in H
s[ print the following on one line:
cG larger number of letters divided by
shMK sum of first items of all items of K
(= the total number of letters)
d space
?H"upp""low" "upp" if H is 1 (for uppercase), otherwise "low"
"ercase "ercase"
CJam, 47 45 bytes
q__eu-\_el-]:,_:+df/" low upp"4/.+:e>"ercase"
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.
Seriously, 58 bytes
" upp"" low"k"ercase"@+╗,;;ú;û+∩@-@-;l@ú@-l/;1-k;i<@╜@ZEεj
Hex Dump:
22207570702222206c6f77226b2265726361736522402bbb2c3b3ba33b
962bef402d402d3b6c40a3402d6c2f3b312d6b3b693c40bd405a45ee6a
It only works on the downloadable interpreter...the online one is still broken.
Explanation:
" upp"" low"k"ercase"@+╗ Put [" lowercase"," uppercase"]
in reg0
,;;ú;û+∩@-@- Read input, remove non-alpha
;l@ Put its length below it
ú@- Delete lowercase
l Get its length
/ Get the ratio of upper/total
;1-k Make list [upp-ratio,low-ratio]
;i< Push 1 if low-ratio is higher
@ Move list to top
╜@Z Zip it with list from reg0
E Pick the one with higher ratio
εj Convert list to string.
Gema, 125 characters
\A=@set{l;0}@set{u;0}
<J1>=@incr{l}
<K1>=@incr{u}
?=
\Z=0.@div{@cmpn{$l;$u;$u;;$l}00;@add{$l;$u}} @cmpn{$l;$u;upp;;low}ercase
Sample run:
bash-4.3$ for input in 'PrOgRaMiNgPuZzLeS & CoDe GoLf' 'DowNGoAT RiGHtGoAt LeFTGoat UpGoAT' 'Foo BaR Baz'; do
> gema '\A=@set{l;0}@set{u;0};<J1>=@incr{l};<K1>=@incr{u};?=;\Z=0.@div{@cmpn{$l;$u;$u;;$l}00;@add{$l;$u}} @cmpn{$l;$u;upp;;low}ercase' <<< "$input"
> echo " <- $input"
> done
0.52 uppercase <- PrOgRaMiNgPuZzLeS & CoDe GoLf
0.58 uppercase <- DowNGoAT RiGHtGoAt LeFTGoat UpGoAT
0.55 lowercase <- Foo BaR Baz
Perl 6, 91 70 69 63 61 bytes
{($/=($/=@=.comb(/\w/)).grep(*~&' 'ne' ')/$/);"{$/>.5??$/!!1-$/} {<low upp>[$/>.5]}ercase"} # 91
{$/=m:g{<upper>}/m:g{\w};"{$/>.5??$/!!1-$/} {<low upp>[$/>.5]}ercase"} # 70
{"{($/=m:g{<upper>}/m:g{\w})>.5??$/!!1-$/} {<low upp>[$/>.5]}ercase"} # 69
{"{($/=m:g{<upper>}/m:g{\w})>.5??"$/ upp"!!1-$/~' low'}ercase"} # 63
{"{($/=m:g{<:Lu>}/m:g{\w})>.5??"$/ upp"!!1-$/~' low'}ercase"} # 61
Usage:
# give it a lexical name
my &code = {...}
.say for (
'PrOgRaMiNgPuZzLeS & CoDe GoLf',
'DowNGoAT RiGHtGoAt LeFTGoat UpGoAT',
'Foo BaR Baz',
)».&code;
0.52 uppercase
0.580645 uppercase
0.555556 lowercase
Julia, 76 74 bytes
s->(x=sum(isupper,s)/sum(isalpha,s);(x>0.5?"$x upp":"$(1-x) low")"ercase")
This is a lambda function that accepts a string and returns a string. To call it, assign it to a variable.
Ungolfed:
function f(s::AbstractString)
# Compute the proportion of uppercase letters
x = sum(isupper, s) / sum(isalpha, s)
# Return a string construct as x or 1-x and the appropriate case
(x > 0.5 ? "$x upp" : "$(1-x) low") * "ercase"
end
Saved 2 bytes thanks to edc65!
MATL, 49 50 bytes
Uses current version (4.1.1) of the language, which is earlier than the challenge.
jt3Y2m)tk=Ymt.5<?1w-YU' upp'h}YU' low'h]'ercase'h
Examples
>> matl
> jt3Y2m)tk=Ymt.5<?1w-YU' upp'h}YU' low'h]'ercase'h
>
> PrOgRaMiNgPuZzLeS & CoDe GoLf
0.52 uppercase
>> matl
> jt3Y2m)tk=Ymt.5<?1w-YU' upp'h}YU' low'h]'ercase'h
>
> Foo BaR Baz
0.55556 lowercase
Explanation
j % input string
t3Y2m) % duplicate. Keep only letters
tk=Ym % duplicate. Proportion of lowercase letters
t.5<? % if less than .5
1w- % compute complement of proportion
YU' upp'h % convert to string and append ' upp'
} % else
YU' low'h % convert to string and append ' low'
] % end
'ercase' % append 'ercase'
Mathematica, 139 105 bytes
a=ToString;If[(b=1.#~(c=StringCount)~Alphabet[]/c[#,_?LetterQ])<.5,a[1-b]<>" upp",a@b<>" low"]<>"ercase"&
Verbose code is scary, but I'll have to live with it...

