Cody

Solution 1695886

Submitted on 19 Dec 2018 by Augusto Mazzei
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
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 = 9 ratio = -4 most = -4 errpos = 1 trueseq = 9 -36 144 -576 2304 -9216 36864 -147456 589824 -2359296 most = -4 errpos = 2 trueseq = 9 -36 144 -576 2304 -9216 36864 -147456 589824 -2359296 most = -4 errpos = 3 trueseq = 9 -36 144 -576 2304 -9216 36864 -147456 589824 -2359296 most = -4 errpos = 4 trueseq = 9 -36 144 -576 2304 -9216 36864 -147456 589824 -2359296 most = -4 errpos = 5 trueseq = 9 -36 144 -576 2304 -9216 36864 -147456 589824 -2359296 most = -4 errpos = 6 trueseq = 9 -36 144 -576 2304 -9216 36864 -147456 589824 -2359296 most = -4 errpos = 7 trueseq = 9 -36 144 -576 2304 -9216 36864 -147456 589824 -2359296 most = -4 errpos = 8 trueseq = 9 -36 144 -576 2304 -9216 36864 -147456 589824 -2359296 most = -4 errpos = 9 trueseq = 9 -36 144 -576 2304 -9216 36864 -147456 589824 -2359296 most = -4 errpos = 10 trueseq = 9 -36 144 -576 2304 -9216 36864 -147456 589824 -2359296

2   Pass
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 = 8 ratio = -9 most = -9 errpos = 1 trueseq = 1.0e+14 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0003 -0.0025 0.0226 -0.2033 1.8301 most = -9 errpos = 2 trueseq = 1.0e+14 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0003 -0.0025 0.0226 -0.2033 1.8301 most = -9 errpos = 3 trueseq = 1.0e+14 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0003 -0.0025 0.0226 -0.2033 1.8301 most = -9 errpos = 4 trueseq = 1.0e+14 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0003 -0.0025 0.0226 -0.2033 1.8301 most = -9 errpos = 5 trueseq = 1.0e+14 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0003 -0.0025 0.0226 -0.2033 1.8301 most = -9 errpos = 6 trueseq = 1.0e+14 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0003 -0.0025 0.0226 -0.2033 1.8301 most = -9 errpos = 7 trueseq = 1.0e+14 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0003 -0.0025 0.0226 -0.2033 1.8301 most = -9 errpos = 8 trueseq = 1.0e+14 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0003 -0.0025 0.0226 -0.2033 1.8301 most = -9 errpos = 9 trueseq = 1.0e+14 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0003 -0.0025 0.0226 -0.2033 1.8301 most = -9 errpos = 10 trueseq = 1.0e+14 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0003 -0.0025 0.0226 -0.2033 1.8301 most = -9 errpos = 11 trueseq = 1.0e+14 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0003 -0.0025 0.0226 -0.2033 1.8301 most = -9 errpos = 12 trueseq = 1.0e+14 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0003 -0.0025 0.0226 -0.2033 1.8301 most = -9 errpos = 13 trueseq = 1.0e+14 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0003 -0.0025 0.0226 -0.2033 1.8301 most = -9 errpos = 14 trueseq = 1.0e+14 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0003 -0.0025 0.0226 -0.2033 1.8301 most = -9 errpos = 15 trueseq = 1.0e+14 * 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0003 -0.0025 0.0226 -0.2033 1.8301

Suggested Problems

More from this Author9