Cody

# Problem 645. Getting the indices from a vector

Solution 1937906

Submitted on 16 Sep 2019 by Eilish O'Grady
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
out = [3 4]; vec = [11 22 33 44]; thresh = 25; assert(isequal(findIndices(vec, thresh),out))

out_initial = 4 vi = 1 2 3 4 vi = 0 2 3 4 vi = 0 0 3 4 vi = 0 0 1 4 vi = 0 0 1 1 out = 3 4

2   Pass
out = [1 2]; vec = [33 44 11 22]; thresh = 25; assert(isequal(findIndices(vec, thresh),out))

out_initial = 4 vi = 1 2 3 4 vi = 1 2 3 4 vi = 1 1 3 4 vi = 1 1 0 4 vi = 1 1 0 0 out = 1 2

3   Pass
out = 5:10; vec = 10:10:100; thresh = 45; assert(isequal(findIndices(vec, thresh),out))

out_initial = 10 vi = 1 2 3 4 5 6 7 8 9 10 vi = 0 2 3 4 5 6 7 8 9 10 vi = 0 0 3 4 5 6 7 8 9 10 vi = 0 0 0 4 5 6 7 8 9 10 vi = 0 0 0 0 5 6 7 8 9 10 vi = 0 0 0 0 1 6 7 8 9 10 vi = 0 0 0 0 1 1 7 8 9 10 vi = 0 0 0 0 1 1 1 8 9 10 vi = 0 0 0 0 1 1 1 1 9 10 vi = 0 0 0 0 1 1 1 1 1 10 vi = 0 0 0 0 1 1 1 1 1 1 out = 5 6 7 8 9 10

4   Pass
out = [1 3 4 6 8]; vec = [12 10 13 14 9 17 5 18]; thresh = 11; assert(isequal(findIndices(vec, thresh),out))

out_initial = 8 vi = 1 2 3 4 5 6 7 8 vi = 1 2 3 4 5 6 7 8 vi = 1 0 3 4 5 6 7 8 vi = 1 0 1 4 5 6 7 8 vi = 1 0 1 1 5 6 7 8 vi = 1 0 1 1 0 6 7 8 vi = 1 0 1 1 0 1 7 8 vi = 1 0 1 1 0 1 0 8 vi = 1 0 1 1 0 1 0 1 out = 1 3 4 6 8

5   Pass
out = [1:3 7:9]; vec = [50 55 60 15 10 5 43 44 97 41]; thresh = 42; assert(isequal(findIndices(vec, thresh),out))

out_initial = 10 vi = 1 2 3 4 5 6 7 8 9 10 vi = 1 2 3 4 5 6 7 8 9 10 vi = 1 1 3 4 5 6 7 8 9 10 vi = 1 1 1 4 5 6 7 8 9 10 vi = 1 1 1 0 5 6 7 8 9 10 vi = 1 1 1 0 0 6 7 8 9 10 vi = 1 1 1 0 0 0 7 8 9 10 vi = 1 1 1 0 0 0 1 8 9 10 vi = 1 1 1 0 0 0 1 1 9 10 vi = 1 1 1 0 0 0 1 1 1 10 vi = 1 1 1 0 0 0 1 1 1 0 out = 1 2 3 7 8 9

6   Pass
out = 5:8; vec = [10 12 14 16 18 20 22 23 7 8 9]; thresh = 17; assert(isequal(findIndices(vec, thresh),out))

out_initial = 11 vi = 1 2 3 4 5 6 7 8 9 10 11 vi = 0 2 3 4 5 6 7 8 9 10 11 vi = 0 0 3 4 5 6 7 8 9 10 11 vi = 0 0 0 4 5 6 7 8 9 10 11 vi = 0 0 0 0 5 6 7 8 9 10 11 vi = 0 0 0 0 1 6 7 8 9 10 11 vi = 0 0 0 0 1 1 7 8 9 10 11 vi = 0 0 0 0 1 1 1 8 9 10 11 vi = 0 0 0 0 1 1 1 1 9 10 11 vi = 0 0 0 0 1 1 1 1 0 10 11 vi = 0 0 0 0 1 1 1 1 0 0 11 vi = 0 0 0 0 1 1 1 1 0 0 0 out = 5 6 7 8

7   Pass
out = [2 4:5 8 12:14 16]; vec = [10 81 24 65 97 13 45 68 24 35 16 79 123 76 45 60]; thresh = 51; assert(isequal(findIndices(vec, thresh),out))

out_initial = 16 vi = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 vi = 0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 vi = 0 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 vi = 0 1 0 4 5 6 7 8 9 10 11 12 13 14 15 16 vi = 0 1 0 1 5 6 7 8 9 10 11 12 13 14 15 16 vi = 0 1 0 1 1 6 7 8 9 10 11 12 13 14 15 16 vi = 0 1 0 1 1 0 7 8 9 10 11 12 13 14 15 16 vi = 0 1 0 1 1 0 0 8 9 10 11 12 13 14 15 16 vi = 0 1 0 1 1 0 0 1 9 10 11 12 13 14 15 16 vi = 0 1 0 1 1 0 0 1 0 10 11 12 13 14 15 16 vi = 0 1 0 1 1 0 0 1 0 0 11 12 13 14 15 16 vi = 0 1 0 1 1 0 0 1 0 0 0 12 13 14 15 16 vi = 0 1 0 1 1 0 0 1 0 0 0 1 13 14 15 16 vi = 0 1 0 1 1 0 0 1 0 0 0 1 1 14 15 16 vi = 0 1 0 1 1 0 0 1 0 0 0 1 1 1 15 16 vi = 0 1 0 1 1 0 0 1 0 0 0 1 1 1 0 16 vi = 0 1 0 1 1 0 0 1 0 0 0 1 1 1 0 1 out = 2 4 5 8 12 13 14 16

8   Pass
out = 1:2:9; vec = [11 9 12 8 13 7 14 6 15 5]; thresh = 10; assert(isequal(findIndices(vec, thresh),out))

out_initial = 10 vi = 1 2 3 4 5 6 7 8 9 10 vi = 1 2 3 4 5 6 7 8 9 10 vi = 1 0 3 4 5 6 7 8 9 10 vi = 1 0 1 4 5 6 7 8 9 10 vi = 1 0 1 0 5 6 7 8 9 10 vi = 1 0 1 0 1 6 7 8 9 10 vi = 1 0 1 0 1 0 7 8 9 10 vi = 1 0 1 0 1 0 1 8 9 10 vi = 1 0 1 0 1 0 1 0 9 10 vi = 1 0 1 0 1 0 1 0 1 10 vi = 1 0 1 0 1 0 1 0 1 0 out = 1 3 5 7 9