c#, using linq, input validations omitted:
string evenOrOdd(string digitsOnly)
var evens = digitsOnly.Count(c => Char.GetNumericValue(c) % 2 == 0);
var odds = digitsOnly.Length - evens;
return evens > odds ?
"Even is greater than Odd" :
evens < odds ?
"Odd is greater than Even" :
"Even and Odd are the same";
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.