Back
Close

Even minus odd

Statement

 Goal

Given an integer N, you have to return the difference D between the sum of the digits at even positions (first digit at position 0) and the sum of the digits at odd positions.
Input
Line 1 : An integer N
Output
Line 1 : D = Sum of digits at even positions - Sum of digits at odd positions
Constraints
0<=N<2^31
-50<D<50
Example
Input
125689
Output
-3

Game modes
Fastest, Shortest

Test cases
Test 1 Test
Input
125689
Output
-3

Validator 1 Validator
Input
10
Output
1

Test 2 Test
Input
1
Output
1

Validator 2 Validator
Input
51364
Output
5

Test 3 Test
Input
1155448877
Output
0

Validator 3 Validator
Input
87541
Output
3

Test 4 Test
Input
90909090
Output
36

Validator 4 Validator
Input
19090909
Output
-35

Test 5 Test
Input
15050505
Output
-19

Validator 5 Validator
Input
9547236
Output
6

Solution language

Solution

Stub generator input