D version, assuming that the string of numbers is a string with integers separated by spaces:
importstd.stdio:writeln;importstd.array:split;importstd.conv:to;importstd.algorithm.iteration:map,sum;stringcompareEvenOdd(stringnumbers){autoresult=numbers.split().map!(a=>to!int(a)).map!(a=>a%2==0?a:-a).sum();returnresult<0?"Odd is greater than Even":(result>0?"Even is greater than Odd":"Even and Odd are the same");}voidmain(){compareEvenOdd("1 2 3 4 5 6 7 8 9").writeln();compareEvenOdd("1 3 6 98 35").writeln();compareEvenOdd("1 1 2 1 1 2 1 1 2").writeln();}
Output:
Odd is greater than Even
Even is greater than Odd
Even and Odd are the same
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
D version, assuming that the string of numbers is a string with integers separated by spaces:
Output: