Cody

# Problem 49. Sums with Excluded Digits

Solution 1200141

Submitted on 29 May 2017 by Ayanle Aden
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 = 20; m = 5; total = 190; assert(isequal(no_digit_sum(n,m),total))

Vec = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 cellVec = cell [1] cellVec = 1×2 cell array [1] [2] cellVec = 1×3 cell array [1] [2] [3] cellVec = 1×4 cell array [1] [2] [3] [4] cellVec = 1×5 cell array [1] [2] [3] [4] [5] cellVec = 1×6 cell array [1] [2] [3] [4] [5] [6] cellVec = 1×7 cell array [1] [2] [3] [4] [5] [6] [7] cellVec = 1×8 cell array [1] [2] [3] [4] [5] [6] [7] [8] cellVec = 1×9 cell array [1] [2] [3] [4] [5] [6] [7] [8] [9] cellVec = 1×10 cell array [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] cellVec = 1×11 cell array [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] cellVec = 1×12 cell array [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×13 cell array [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×14 cell array [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×15 cell array [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×16 cell array [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×17 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Column 17 [1×2 double] cellVec = 1×18 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 18 [1×2 double] [1×2 double] cellVec = 1×19 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 19 [1×2 double] [1×2 double] [1×2 double] cellVec = 1×20 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 20 [1×2 double] [1×2 double] [1×2 double] [1×2 double] Vec = 1 2 3 4 0 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Vec = 1 2 3 4 0 6 7 8 9 10 11 12 13 14 0 16 17 18 19 20 total = 190

2   Pass
n = 10; m = 5; total = 50; assert(isequal(no_digit_sum(n,m),total))

Vec = 1 2 3 4 5 6 7 8 9 10 cellVec = cell [1] cellVec = 1×2 cell array [1] [2] cellVec = 1×3 cell array [1] [2] [3] cellVec = 1×4 cell array [1] [2] [3] [4] cellVec = 1×5 cell array [1] [2] [3] [4] [5] cellVec = 1×6 cell array [1] [2] [3] [4] [5] [6] cellVec = 1×7 cell array [1] [2] [3] [4] [5] [6] [7] cellVec = 1×8 cell array [1] [2] [3] [4] [5] [6] [7] [8] cellVec = 1×9 cell array [1] [2] [3] [4] [5] [6] [7] [8] [9] cellVec = 1×10 cell array [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] Vec = 1 2 3 4 0 6 7 8 9 10 total = 50

3   Pass
n = 33; m = 3; total = 396; assert(isequal(no_digit_sum(n,m),total))

Vec = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Columns 30 through 33 30 31 32 33 cellVec = cell [1] cellVec = 1×2 cell array [1] [2] cellVec = 1×3 cell array [1] [2] [3] cellVec = 1×4 cell array [1] [2] [3] [4] cellVec = 1×5 cell array [1] [2] [3] [4] [5] cellVec = 1×6 cell array [1] [2] [3] [4] [5] [6] cellVec = 1×7 cell array [1] [2] [3] [4] [5] [6] [7] cellVec = 1×8 cell array [1] [2] [3] [4] [5] [6] [7] [8] cellVec = 1×9 cell array [1] [2] [3] [4] [5] [6] [7] [8] [9] cellVec = 1×10 cell array [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] cellVec = 1×11 cell array [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] cellVec = 1×12 cell array [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×13 cell array [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×14 cell array [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×15 cell array [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×16 cell array [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×17 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Column 17 [1×2 double] cellVec = 1×18 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 18 [1×2 double] [1×2 double] cellVec = 1×19 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 19 [1×2 double] [1×2 double] [1×2 double] cellVec = 1×20 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 20 [1×2 double] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×21 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 21 [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×22 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 22 [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×23 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 23 [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×24 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 24 [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×25 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 25 [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×26 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 26 [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×27 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 27 [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×28 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 27 [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Column 28 [1×2 double] cellVec = 1×29 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 27 [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 28 through 29 [1×2 double] [1×2 double] cellVec = 1×30 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 27 [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 28 through 30 [1×2 double] [1×2 double] [1×2 double] cellVec = 1×31 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 27 [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 28 through 31 [1×2 double] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×32 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 27 [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 28 through 32 [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] cellVec = 1×33 cell array Columns 1 through 16 [1] [2] [3] [4] [5] [6] [7] [8] [9] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 17 through 27 [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Columns 28 through 33 [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] [1×2 double] Vec = Columns 1 through 29 1 2 0 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Columns 30 through 33 30 31 32 33 Vec = Columns 1 through 29 1 2 0 4 5 6 7 8 9 10 11 12 0 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Columns 30 through 33 30 31 32 33 Vec = Columns 1 through 29 1 2 0 4 5 6 7 8 9 10 11 12 0 14 15 16 17 18 19 20 21 22 0 24 25 26 27 28 29 Columns 30 through 33 30 31 32 33 Vec = Columns 1 through 29 1 2 0 4 5 6 7 8 9 10 11 12 0 14 15 16 17 18 19 20 21 22 0 24 25 26 27 28 29 Columns 30 through 33 0 31 32 33 Vec...