Cody

Problem 74. Balanced number

Solution 701319

Submitted on 15 Jul 2015 by Mark Orloff
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))

num = 13722 ans = 5 len = 2 front = 0 back = 0 front = 49 back = 50 front = 100 back = 100

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

num = 23567414 ans = 8 len = 4 front = 0 back = 0 front = 50 back = 52 front = 101 back = 101 front = 154 back = 153 front = 208 back = 208

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

num = 20567410 ans = 8 len = 4 front = 0 back = 0 front = 50 back = 48 front = 98 back = 97 front = 151 back = 149 front = 205 back = 204

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

num = 1 ans = 1 len = 0 front = 0 back = 0

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

num = 11111111 ans = 8 len = 4 front = 0 back = 0 front = 49 back = 49 front = 98 back = 98 front = 147 back = 147 front = 196 back = 196

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

num = 12345678 ans = 8 len = 4 front = 0 back = 0 front = 49 back = 56 front = 99 back = 111 front = 150 back = 165 front = 202 back = 218

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

num = 12333 ans = 5 len = 2 front = 0 back = 0 front = 49 back = 51 front = 99 back = 102

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

num = 9898 ans = 4 len = 2 front = 0 back = 0 front = 57 back = 56 front = 113 back = 113

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

num = 469200 ans = 6 len = 3 front = 0 back = 0 front = 52 back = 48 front = 106 back = 96 front = 163 back = 146

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

num = 57666 ans = 5 len = 2 front = 0 back = 0 front = 53 back = 54 front = 108 back = 108