Cody

Problem 2990. Replace every 3rd element in a vector with 4

Solution 2483948

Submitted on 6 Jun 2020 by Ramesh Kumar V
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
x = [11 23 34 43 2 31 6 34 5 45 26 7 78]; y_correct = [11 23 4 43 2 4 6 34 4 45 26 4 78]; assert(isequal(every_3rd_element(x),y_correct))

m = 13 k = 1 k = 2 k = 0 x = 11 23 4 43 2 31 6 34 5 45 26 7 78 k = 1 k = 2 k = 0 x = 11 23 4 43 2 4 6 34 5 45 26 7 78 k = 1 k = 2 k = 0 x = 11 23 4 43 2 4 6 34 4 45 26 7 78 k = 1 k = 2 k = 0 x = 11 23 4 43 2 4 6 34 4 45 26 4 78 k = 1

2   Pass
x = [82 91 13 92 64 10 28 55 96 97 16 98 96 49 81 15 43 92 80 96 66 4 85 94 68 76 75 40 66 18]; y_correct = [82 91 4 92 64 4 28 55 4 97 16 4 96 49 4 15 43 4 80 96 4 4 85 4 68 76 4 40 66 4]; assert(isequal(every_3rd_element(x),y_correct))

m = 30 k = 1 k = 2 k = 0 x = 82 91 4 92 64 10 28 55 96 97 16 98 96 49 81 15 43 92 80 96 66 4 85 94 68 76 75 40 66 18 k = 1 k = 2 k = 0 x = 82 91 4 92 64 4 28 55 96 97 16 98 96 49 81 15 43 92 80 96 66 4 85 94 68 76 75 40 66 18 k = 1 k = 2 k = 0 x = 82 91 4 92 64 4 28 55 4 97 16 98 96 49 81 15 43 92 80 96 66 4 85 94 68 76 75 40 66 18 k = 1 k = 2 k = 0 x = 82 91 4 92 64 4 28 55 4 97 16 4 96 49 81 15 43 92 80 96 66 4 85 94 68 76 75 40 66 18 k = 1 k = 2 k = 0 x = 82 91 4 92 64 4 28 55 4 97 16 4 96 49 4 15 43 92 80 96 66 4 85 94 68 76 75 40 66 18 k = 1 k = 2 k = 0 x = 82 91 4 92 64 4 28 55 4 97 16 4 96 49 4 15 43 4 80 96 66 4 85 94 68 76 75 40 66 18 k = 1 k = 2 k = 0 x = 82 91 4 92 64 4 28 55 4 97 16 4 96 49 4 15 43 4 80 96 4 4 85 94 68 76 75 40 66 18 k = 1 k = 2 k = 0 x = 82 91 4 92 64 4 28 55 4 97 16 4 96 49 4 15 43 4 80 96 4 4 85 4 68 76 75 40 66 18 k = 1 k = 2 k = 0 x = 82 91 4 92 64 4 28 55 4 97 16 4 96 49 4 15 43 4 80 96 4 4 85 4 68 76 4 40 66 18 k = 1 k = 2 k = 0 x = 82 91 4 92 64 4 28 55 4 97 16 4 96 49 4 15 43 4 80 96 4 4 85 4 68 76 4 40 66 4