Cody

# Problem 74. Balanced number

Solution 1765329

Submitted on 28 Mar 2019 by Chidvilashini Modala
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
n = 13722; assert(isequal(isBalanced(n),true))

n1 = 13722 c = 4 k = 2 sum1 = 2 sum2 = 1 n = 1372 n1 = 3722 c = 3 sum1 = 4 sum2 = 4 n = 137 n1 = 722 c = 2

2   Pass
n = 23567414; assert(isequal(isBalanced(n),true))

n1 = 23567414 c = 7 k = 4 sum1 = 4 sum2 = 2 n = 2356741 n1 = 3567414 c = 6 sum1 = 5 sum2 = 5 n = 235674 n1 = 567414 c = 5 sum1 = 9 sum2 = 10 n = 23567 n1 = 67414 c = 4 sum1 = 16 sum2 = 16 n = 2356 n1 = 7414 c = 3

3   Pass
n = 20567410; assert(isequal(isBalanced(n),false))

n1 = 20567410 c = 7 k = 4 sum1 = 0 sum2 = 2 n = 2056741 n1 = 567410 c = 6 sum1 = 1 sum2 = 2 n = 205674 n1 = 567410 c = 5 sum1 = 5 sum2 = 7 n = 20567 n1 = 67410 c = 4 sum1 = 12 sum2 = 13 n = 2056 n1 = 7410 c = 3

4   Pass
n = 1; assert(isequal(isBalanced(n),true))

n1 = 1 c = 0 k = 0

5   Pass
n = 11111111; assert(isequal(isBalanced(n),true))

n1 = 11111111 c = 7 k = 4 sum1 = 1 sum2 = 1 n = 1111111 n1 = 1111111 c = 6 sum1 = 2 sum2 = 2 n = 111111 n1 = 111111 c = 5 sum1 = 3 sum2 = 3 n = 11111 n1 = 11111 c = 4 sum1 = 4 sum2 = 4 n = 1111 n1 = 1111 c = 3

6   Pass
n = 12345678; assert(isequal(isBalanced(n),false))

n1 = 12345678 c = 7 k = 4 sum1 = 8 sum2 = 1 n = 1234567 n1 = 2345678 c = 6 sum1 = 15 sum2 = 3 n = 123456 n1 = 345678 c = 5 sum1 = 21 sum2 = 6 n = 12345 n1 = 45678 c = 4 sum1 = 26 sum2 = 10 n = 1234 n1 = 5678 c = 3

7   Pass
n = 12333; assert(isequal(isBalanced(n),false))

n1 = 12333 c = 4 k = 2 sum1 = 3 sum2 = 1 n = 1233 n1 = 2333 c = 3 sum1 = 6 sum2 = 3 n = 123 n1 = 333 c = 2

8   Pass
n = 9898; assert(isequal(isBalanced(n),true))

n1 = 9898 c = 3 k = 2 sum1 = 8 sum2 = 9 n = 989 n1 = 898 c = 2 sum1 = 17 sum2 = 17 n = 98 n1 = 98 c = 1

9   Pass
n = 469200; assert(isequal(isBalanced(n),false))

n1 = 469200 c = 5 k = 3 sum1 = 0 sum2 = 4 n = 46920 n1 = 69200 c = 4 sum1 = 0 sum2 = 10 n = 4692 n1 = 9200 c = 3 sum1 = 2 sum2 = 19 n = 469 n1 = 200 c = 2

10   Pass
n = 57666; assert(isequal(isBalanced(n),true))

n1 = 57666 c = 4 k = 2 sum1 = 6 sum2 = 5 n = 5766 n1 = 7666 c = 3 sum1 = 12 sum2 = 12 n = 576 n1 = 666 c = 2