Cody

Problem 74. Balanced number

Solution 1378526

Submitted on 13 Dec 2017 by Stuart Briscoe
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))

b = '13722' c = 2 d = '13' e = '22' f = 0 g = 0 f = 1 g = 2 f = 4 g = 4 tf = logical 1

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

b = '23567414' c = 4 d = '2356' e = '7414' f = 0 g = 0 f = 2 g = 7 f = 5 g = 11 f = 10 g = 12 f = 16 g = 16 tf = logical 1

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

b = '20567410' c = 4 d = '2056' e = '7410' f = 0 g = 0 f = 2 g = 7 f = 2 g = 11 f = 7 g = 12 f = 13 g = 12 tf = logical 0

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

b = '1' c = 0 d = 1×0 empty char array e = 1×0 empty char array f = 0 g = 0 tf = logical 1

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

b = '11111111' c = 4 d = '1111' e = '1111' f = 0 g = 0 f = 1 g = 1 f = 2 g = 2 f = 3 g = 3 f = 4 g = 4 tf = logical 1

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

b = '12345678' c = 4 d = '1234' e = '5678' f = 0 g = 0 f = 1 g = 5 f = 3 g = 11 f = 6 g = 18 f = 10 g = 26 tf = logical 0

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

b = '12333' c = 2 d = '12' e = '33' f = 0 g = 0 f = 1 g = 3 f = 3 g = 6 tf = logical 0

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

b = '9898' c = 2 d = '98' e = '98' f = 0 g = 0 f = 9 g = 9 f = 17 g = 17 tf = logical 1

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

b = '469200' c = 3 d = '469' e = '200' f = 0 g = 0 f = 4 g = 2 f = 10 g = 2 f = 19 g = 2 tf = logical 0

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

b = '57666' c = 2 d = '57' e = '66' f = 0 g = 0 f = 5 g = 6 f = 12 g = 12 tf = logical 1