TopcoderArchive
Archive
Algorithm problem

Evenoddity

Problem statement, definition, constraints, and public examples.

Problem Statement

Let's define the evenoddity of an integer x as the sum of its even digits minus the sum of its odd digits. For example, the evenoddity of 239 is (2) - (3 + 9) = -10.

You are given an int X. Return its evenoddity.

Definition

Class:
Evenoddity
Method:
get
Parameters:
int
Returns:
int
Method signature:
int get(int X)
(be sure your method is public)

Constraints

  • X will be between 1 and 10000, inclusive.

Examples

  1. 123
    Returns: -2
    The evenoddity of 123 is (2) - (1 + 3) = -2.
  2. 124
    Returns: 5
    The evenoddity of 124 is (2 + 4) - (1) = 5.
  3. 1
    Returns: -1
  4. 8118
    Returns: 14
  5. 6010
    Returns: 5
Back to all problems