Cody

Problem 74. Balanced number

Solution 2610751

Submitted on 25 Jun 2020 by 春樹 内糸
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))

sn = '13722' an = 5 ln = 2 left = '13' right = '22'

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

sn = '23567414' an = 8 ln = 4 left = '2356' right = '4147'

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

sn = '20567410' an = 8 ln = 4 left = '2056' right = '0147'

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

sn = '1' an = 1 ln = 0 left = 1×0 empty char array right = 1×0 empty char array

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

sn = '11111111' an = 8 ln = 4 left = '1111' right = '1111'

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

sn = '12345678' an = 8 ln = 4 left = '1234' right = '8765'

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

sn = '12333' an = 5 ln = 2 left = '12' right = '33'

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

sn = '9898' an = 4 ln = 2 left = '98' right = '89'

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

sn = '469200' an = 6 ln = 3 left = '469' right = '002'

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

sn = '57666' an = 5 ln = 2 left = '57' right = '66'

Suggested Problems

More from this Author95

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!