In this exercise, we say that a natural number is balanced if the sum of the digits in even positions is equal to the sum of the digits in odd positions. For instance, 1463 and 48015 are balanced numbers.
Write a function that tells if a natural number n is balanced or not.
Interface
C++ | bool is_balanced(int n); |
C | int is_balanced(int n); |
Java | public static boolean isBalanced(int n); |
Python | is_balanced(n) # returns bool |
is_balanced(n: int) -> bool |
Observation You only need to submit the required procedure; your main program will be ignored.
Input
1463 48015 277242355 471003930
Output
1 1 0 0