Cody

# Problem 74. Balanced number

Solution 489113

Submitted on 21 Aug 2014 by Jamie Sargant
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))

n = 13722 y = 5 x = 2 A = 1 3 B = 2 2 C = 1 3 D = 2 2

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

n = 23567414 y = 8 x = 4 A = 2 3 5 6 B = 7 4 1 4 C = 2 3 5 6 D = 7 4 1 4

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

n = 20567410 y = 8 x = 4 A = 2 0 5 6 B = 7 4 1 0 C = 2 0 5 6 D = 7 4 1 0

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

n = 1 y = 1 x = 0 A = Empty string: 0-by-1 B = Empty string: 0-by-1 C = [] D = []

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

n = 11111111 y = 8 x = 4 A = 1 1 1 1 B = 1 1 1 1 C = 1 1 1 1 D = 1 1 1 1

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

n = 12345678 y = 8 x = 4 A = 1 2 3 4 B = 5 6 7 8 C = 1 2 3 4 D = 5 6 7 8

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

n = 12333 y = 5 x = 2 A = 1 2 B = 3 3 C = 1 2 D = 3 3

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

n = 9898 y = 4 x = 2 A = 9 8 B = 9 8 C = 9 8 D = 9 8

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

n = 469200 y = 6 x = 3 A = 4 6 9 B = 2 0 0 C = 4 6 9 D = 2 0 0

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

n = 57666 y = 5 x = 2 A = 5 7 B = 6 6 C = 5 7 D = 6 6

### Community Treasure Hunt

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

Start Hunting!