Cody

# Problem 74. Balanced number

Solution 1814580

Submitted on 14 May 2019 by Priysha Aggarwal
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))

a = [] a = 2 n = 1372 a = 2 2 n = 137 a = 2 2 7 n = 13 a = 2 2 7 3 n = 1 a = 2 2 7 3 1 n = 0 b = 2 2 s1 = 4 b = 7 3 1 b = 3 1 s2 = 4 tf = logical 1

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

a = [] a = 4 n = 2356741 a = 4 1 n = 235674 a = 4 1 4 n = 23567 a = 4 1 4 7 n = 2356 a = 4 1 4 7 6 n = 235 a = 4 1 4 7 6 5 n = 23 a = 4 1 4 7 6 5 3 n = 2 a = 4 1 4 7 6 5 3 2 n = 0 b = 4 1 4 7 s1 = 16 b = 6 5 3 2 s2 = 16 tf = logical 1

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

a = [] a = 0 n = 2056741 a = 0 1 n = 205674 a = 0 1 4 n = 20567 a = 0 1 4 7 n = 2056 a = 0 1 4 7 6 n = 205 a = 0 1 4 7 6 5 n = 20 a = 0 1 4 7 6 5 0 n = 2 a = 0 1 4 7 6 5 0 2 n = 0 b = 0 1 4 7 s1 = 12 b = 6 5 0 2 s2 = 13 tf = logical 0

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

a = [] a = 1 n = 0 b = 1×0 empty double row vector s1 = 0 b = 1 b = 1×0 empty double row vector s2 = 0 tf = logical 1

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

a = [] a = 1 n = 1111111 a = 1 1 n = 111111 a = 1 1 1 n = 11111 a = 1 1 1 1 n = 1111 a = 1 1 1 1 1 n = 111 a = 1 1 1 1 1 1 n = 11 a = 1 1 1 1 1 1 1 n = 1 a = 1 1 1 1 1 1 1 1 n = 0 b = 1 1 1 1 s1 = 4 b = 1 1 1 1 s2 = 4 tf = logical 1

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

a = [] a = 8 n = 1234567 a = 8 7 n = 123456 a = 8 7 6 n = 12345 a = 8 7 6 5 n = 1234 a = 8 7 6 5 4 n = 123 a = 8 7 6 5 4 3 n = 12 a = 8 7 6 5 4 3 2 n = 1 a = 8 7 6 5 4 3 2 1 n = 0 b = 8 7 6 5 s1 = 26 b = 4 3 2 1 s2 = 10 tf = logical 0

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

a = [] a = 3 n = 1233 a = 3 3 n = 123 a = 3 3 3 n = 12 a = 3 3 3 2 n = 1 a = 3 3 3 2 1 n = 0 b = 3 3 s1 = 6 b = 3 2 1 b = 2 1 s2 = 3 tf = logical 0

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

a = [] a = 8 n = 989 a = 8 9 n = 98 a = 8 9 8 n = 9 a = 8 9 8 9 n = 0 b = 8 9 s1 = 17 b = 8 9 s2 = 17 tf = logical 1

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

a = [] a = 0 n = 46920 a = 0 0 n = 4692 a = 0 0 2 n = 469 a = 0 0 2 9 n = 46 a = 0 0 2 9 6 n = 4 a = 0 0 2 9 6 4 n = 0 b = 0 0 2 s1 = 2 b = 9 6 4 s2 = 19 tf = logical 0

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

a = [] a = 6 n = 5766 a = 6 6 n = 576 a = 6 6 6 n = 57 a = 6 6 6 7 n = 5 a = 6 6 6 7 5 n = 0 b = 6 6 s1 = 12 b = 6 7 5 b = 7 5 s2 = 12 tf = logical 1