Cody

# Problem 1941. Lowest sum from a group of digits

Solution 2129741

Submitted on 15 Feb 2020
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   Fail
x = 0:3; y_correct = 33; assert(isequal(lowest_number(x),y_correct))

xx = 1 2 3 z = 0 xx = 1 0 2 3

Error using str2num (line 35) Input must be a character vector or string scalar. Error in lowest_number (line 6) sum(str2num(xx+'0')) Error in Test1 (line 1) x = 0:3; y_correct = 33; assert(isequal(lowest_number(x),y_correct))

2   Fail
x=[1 2 3 7 8 9] ; y_correct = 417; assert(isequal(lowest_number(x),y_correct))

xx = 1 2 3 7 8 9 z = 1×0 empty double row vector xx = 1 3 8 2 7 9

Error using str2num (line 35) Input must be a character vector or string scalar. Error in lowest_number (line 6) sum(str2num(xx+'0')) Error in Test2 (line 2) assert(isequal(lowest_number(x),y_correct))

3   Fail
x=[7 8 9 7 8 9] ; y_correct = 1578; assert(isequal(lowest_number(x),y_correct))

xx = 7 7 8 8 9 9 z = 1×0 empty double row vector xx = 7 8 9 7 8 9

Error using str2num (line 35) Input must be a character vector or string scalar. Error in lowest_number (line 6) sum(str2num(xx+'0')) Error in Test3 (line 2) assert(isequal(lowest_number(x),y_correct))

4   Fail
x = 0:9; y_correct = 34047; assert(isequal(lowest_number(x),y_correct))

xx = 1 2 3 4 5 6 7 8 9 z = 0 xx = 1 0 4 6 8 2 3 5 7 9

Error using str2num (line 35) Input must be a character vector or string scalar. Error in lowest_number (line 6) sum(str2num(xx+'0')) Error in Test4 (line 1) x = 0:9; y_correct = 34047; assert(isequal(lowest_number(x),y_correct))

5   Fail
x=7*[ones(1,5) zeros(1,7)]; y_correct=1400084; assert(isequal(lowest_number(x),y_correct))

xx = 7 7 7 7 7 z = 0 0 0 0 0 0 0 xx = 7 0 0 0 0 7 7 0 0 0 7 7

Error using str2num (line 35) Input must be a character vector or string scalar. Error in lowest_number (line 6) sum(str2num(xx+'0')) Error in Test5 (line 1) x=7*[ones(1,5) zeros(1,7)]; y_correct=1400084; assert(isequal(lowest_number(x),y_correct))

6   Fail
x=[ones(1,8) zeros(1,10)]; y_correct=200000222; assert(isequal(lowest_number(x),y_correct))

xx = 1 1 1 1 1 1 1 1 z = 0 0 0 0 0 0 0 0 0 0 xx = 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 1 1 1

Error using str2num (line 35) Input must be a character vector or string scalar. Error in lowest_number (line 6) sum(str2num(xx+'0')) Error in Test6 (line 1) x=[ones(1,8) zeros(1,10)]; y_correct=200000222; assert(isequal(lowest_number(x),y_correct))

7   Fail
x = [0:9 1:8]; y_correct = 225802467; assert(isequal(lowest_number(x),y_correct))

xx = 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 z = 0 xx = 1 0 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 9

Error using str2num (line 35) Input must be a character vector or string scalar. Error in lowest_number (line 6) sum(str2num(xx+'0')) Error in Test7 (line 1) x = [0:9 1:8]; y_correct = 225802467; assert(isequal(lowest_number(x),y_correct))

8   Fail
x=[randperm(10)-1 randperm(6)]; y_correct=22580247; assert(isequal(lowest_number(x),y_correct))

xx = 1 1 2 2 3 3 4 4 5 5 6 6 7 8 9 z = 0 xx = 1 0 2 3 4 5 6 8 1 2 3 4 5 6 7 9

Error using str2num (line 35) Input must be a character vector or string scalar. Error in lowest_number (line 6) sum(str2num(xx+'0')) Error in Test8 (line 1) x=[randperm(10)-1 randperm(6)]; y_correct=22580247; assert(isequal(lowest_number(x),y_correct))