Cody

# Problem 74. Balanced number

Solution 298561

Submitted on 8 Aug 2013 by Ashutosh datar
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 = 13722 b = 5 p = 2 first = 0 last = 0 first = 1 last = 2 first = 4 last = 4 tf = 1

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

a = 23567414 b = 8 p = 4 first = 0 last = 0 first = 2 last = 4 first = 5 last = 5 first = 10 last = 9 first = 16 last = 16 tf = 1

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

a = 20567410 b = 8 p = 4 first = 0 last = 0 first = 2 last = 0 first = 2 last = 1 first = 7 last = 5 first = 13 last = 12 tf = 0

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

a = 1 b = 1 p = 0 first = 0 last = 0 tf = 1

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

a = 11111111 b = 8 p = 4 first = 0 last = 0 first = 1 last = 1 first = 2 last = 2 first = 3 last = 3 first = 4 last = 4 tf = 1

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

a = 12345678 b = 8 p = 4 first = 0 last = 0 first = 1 last = 8 first = 3 last = 15 first = 6 last = 21 first = 10 last = 26 tf = 0

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

a = 12333 b = 5 p = 2 first = 0 last = 0 first = 1 last = 3 first = 3 last = 6 tf = 0

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

a = 9898 b = 4 p = 2 first = 0 last = 0 first = 9 last = 8 first = 17 last = 17 tf = 1

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

a = 469200 b = 6 p = 3 first = 0 last = 0 first = 4 last = 0 first = 10 last = 0 first = 19 last = 2 tf = 0

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

a = 57666 b = 5 p = 2 first = 0 last = 0 first = 5 last = 6 first = 12 last = 12 tf = 1