Cody

# Problem 2801. geometric progression

Solution 1695876

Submitted on 19 Dec 2018
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
nterms = 10; term0 = randi(10) ratio = (-1)^randi(2)*randi(10) correctsequence = term0*ratio.^(0:nterms-1); for position = 1:nterms errorsequence = correctsequence; errorsequence(position) = errorsequence(position) + (-1)^randi(2)*randi(50); [errorposition, truesequence] = find_error(errorsequence); assert(errorposition == position && isequal(truesequence, correctsequence), 'failed test 1 at position %d', position); end

term0 = 10 ratio = -1 most = -1 errpos = 1 trueseq = 10 -10 10 -10 10 -10 10 -10 10 -10 most = -1 errpos = 2 trueseq = 10 -10 10 -10 10 -10 10 -10 10 -10 most = -1 errpos = 3 trueseq = 10 -10 10 -10 10 -10 10 -10 10 -10 most = -1 errpos = 4 trueseq = 10 -10 10 -10 10 -10 10 -10 10 -10 most = -1 errpos = 5 trueseq = 10 -10 10 -10 10 -10 10 -10 10 -10 most = -1 errpos = 6 trueseq = 10 -10 10 -10 10 -10 10 -10 10 -10 most = -1 errpos = 7 trueseq = 10 -10 10 -10 10 -10 10 -10 10 -10 most = -1 errpos = 8 trueseq = 10 -10 10 -10 10 -10 10 -10 10 -10 most = -1 errpos = 9 trueseq = 10 -10 10 -10 10 -10 10 -10 10 -10 most = -1 errpos = 9 trueseq = 10 -10 10 -10 10 -10 10 -10 -9 9

failed test 1 at position 10

2   Fail
nterms = 15; term0 = randi(10) ratio = (-1)^randi(2)*randi(10) correctsequence = term0*ratio.^(0:nterms-1); for position = 1:nterms errorsequence = correctsequence; errorsequence(position) = errorsequence(position) + (-1)^randi(2)*randi(50); [errorposition, truesequence] = find_error(errorsequence); assert(errorposition == position && isequal(truesequence, correctsequence), 'failed test 2 at position %d', position); end

term0 = 7 ratio = -6 most = -6 errpos = 1 trueseq = 1.0e+11 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0001 -0.0007 0.0042 -0.0254 0.1524 -0.9142 5.4855 most = -6 errpos = 2 trueseq = 1.0e+11 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0001 -0.0007 0.0042 -0.0254 0.1524 -0.9142 5.4855 most = -6 errpos = 3 trueseq = 1.0e+11 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0001 -0.0007 0.0042 -0.0254 0.1524 -0.9142 5.4855 most = -6 errpos = 4 trueseq = 1.0e+11 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0001 -0.0007 0.0042 -0.0254 0.1524 -0.9142 5.4855 most = -6 errpos = 5 trueseq = 1.0e+11 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0001 -0.0007 0.0042 -0.0254 0.1524 -0.9142 5.4855 most = -6 errpos = 6 trueseq = 1.0e+11 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0001 -0.0007 0.0042 -0.0254 0.1524 -0.9142 5.4855 most = -6 errpos = 7 trueseq = 1.0e+11 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0001 -0.0007 0.0042 -0.0254 0.1524 -0.9142 5.4855 most = -6 errpos = 8 trueseq = 1.0e+11 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0001 -0.0007 0.0042 -0.0254 0.1524 -0.9142 5.4855 most = -6 errpos = 9 trueseq = 1.0e+11 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0001 -0.0007 0.0042 -0.0254 0.1524 -0.9142 5.4855 most = -6 errpos = 10 trueseq = 1.0e+11 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0001 -0.0007 0.0042 -0.0254 0.1524 -0.9142 5.4855 most = -6 errpos = 11 trueseq = 1.0e+11 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0001 -0.0007 0.0042 -0.0254 0.1524 -0.9142 5.4855 most = -6 errpos = 12 trueseq = 1.0e+11 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0001 -0.0007 0.0042 -0.0254 0.1524 -0.9142 5.4855 most = -6 errpos = 13 trueseq = 1.0e+11 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0001 -0.0007 0.0042 -0.0254 0.1524 -0.9142 5.4855 most = -6 errpos = 14 trueseq = 1.0e+11 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0001 -0.0007 0.0042 -0.0254 0.1524 -0.9142 5.4855 most = -6 errpos = 14 trueseq = 1.0e+11 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0001 -0.0007 0.0042 -0.0254 0.1524 -0.9142 5.4855

failed test 2 at position 15