Cody

# Problem 2800. arithmetic progression

Solution 2167478

Submitted on 20 Mar 2020
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); increment = (-1)^randi(2)*randi(10); correctsequence = term0:increment:term0+(nterms-1)*increment; 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

errsq = 3 8 15 22 29 36 43 50 57 64 truesq = 1 8 15 22 22 29 36 43 50 57 64 err = 1

failed test 1 at position 1

2   Fail
nterms = 201; term0 = randi(10); increment = (-1)^randi(2)*randi(10); correctsequence = term0:increment:term0+(nterms-1)*increment; for position = 1:10: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

errsq = Columns 1 through 15 -23 -6 -16 -26 -36 -46 -56 -66 -76 -86 -96 -106 -116 -126 -136 Columns 16 through 30 -146 -156 -166 -176 -186 -196 -206 -216 -226 -236 -246 -256 -266 -276 -286 Columns 31 through 45 -296 -306 -316 -326 -336 -346 -356 -366 -376 -386 -396 -406 -416 -426 -436 Columns 46 through 60 -446 -456 -466 -476 -486 -496 -506 -516 -526 -536 -546 -556 -566 -576 -586 Columns 61 through 75 -596 -606 -616 -626 -636 -646 -656 -666 -676 -686 -696 -706 -716 -726 -736 Columns 76 through 90 -746 -756 -766 -776 -786 -796 -806 -816 -826 -836 -846 -856 -866 -876 -886 Columns 91 through 105 -896 -906 -916 -926 -936 -946 -956 -966 -976 -986 -996 -1006 -1016 -1026 -1036 Columns 106 through 120 -1046 -1056 -1066 -1076 -1086 -1096 -1106 -1116 -1126 -1136 -1146 -1156 -1166 -1176 -1186 Columns 121 through 135 -1196 -1206 -1216 -1226 -1236 -1246 -1256 -1266 -1276 -1286 -1296 -1306 -1316 -1326 -1336 Columns 136 through 150 -1346 -1356 -1366 -1376 -1386 -1396 -1406 -1416 -1426 -1436 -1446 -1456 -1466 -1476 -1486 Columns 151 through 165 -1496 -1506 -1516 -1526 -1536 -1546 -1556 -1566 -1576 -1586 -1596 -1606 -1616 -1626 -1636 Columns 166 through 180 -1646 -1656 -1666 -1676 -1686 -1696 -1706 -1716 -1726 -1736 -1746 -1756 -1766 -1776 -1786 Columns 181 through 195 -1796 -1806 -1816 -1826 -1836 -1846 -1856 -1866 -1876 -1886 -1896 -1906 -1916 -1926 -1936 Columns 196 through 201 -1946 -1956 -1966 -1976 -1986 -1996 truesq = Columns 1 through 15 4 -6 -16 -26 -26 -36 -46 -56 -66 -76 -86 -96 -106 -116 -126 Columns 16 through 30 -136 -146 -156 -166 -176 -186 -196 -206 -216 -226 -236 -246 -256 -266 -276 Columns 31 through 45 -286 -296 -306 -316 -326 -336 -346 -356 -366 -376 -386 -396 -406 -416 -426 Columns 46 through 60 -436 -446 -456 -466 -476 -486 -496 -506 -516 -526 -536 -546 -556 -566 -576 Columns 61 through 75 -586 -596 -606 -616 -626 -636 -646 -656 -666 -676 -686 -696 -706 -716 -726 Columns 76 through 90 -736 -746 -756 -766 -776 -786 -796 -806 -816 -826 -836 -846 -856 -866 -876 Columns 91 through 105 -886 -896 -906 -916 -926 -936 -946 -956 -966 -976 -986 -996 -1006 -1016 -1026 Columns 106 through 120 -1036 -1046 -1056 -1066 -1076 -1086 -1096 -1106 -1116 -1126 -1136 -1146 -1156 -1166 -1176 Columns 121 through 135 -1186 -1196 -1206 -1216 -1226 -1236 -1246 -1256 -1266 -1276 -1286 -1296 -1306 -1316 -1326 Columns 136 through 150 -1336 -1346 -1356 -1366 -1376 -1386 -1396 -1406 -1416 -1426 -1436 -1446 -1456 -1466 -1476 Columns 151 through 165 -1486 -1496 -1506 -1516 -1526 -1536 -1546 -1556 -1566 -1576 -1586 -1596 -1606 -1616 -1626 Columns 166 through 180 -1636 -1646 -1656 -1666 -1676 -1686 -1696 -1706 -1716 -1726 -1736 -1746 -1756 -1766 -1776 Columns 181 through 195 -1786 -1796 -1806 -1816 -1826 -1836 -1846 -1856 -1866 -1876 -1886 -1896 -1906 -1916 -1926 Columns 196 through 202 -1936 -1946 -1956 -1966 -1976 -1986 -1996 err = 1

failed test 2 at position 1