Cody

# Problem 2800. arithmetic progression

Solution 1992606

Submitted on 27 Oct 2019
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

l = 10 ans = Columns 1 through 30 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 Columns 31 through 60 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 Columns 61 through 81 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

Output argument "errorposition" (and maybe others) not assigned during call to "find_error". Error in Test1 (line 8) [errorposition, truesequence] = find_error(errorsequence);

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

l = -10 ans = Columns 1 through 15 -1990 -1989 -1988 -1987 -1986 -1985 -1984 -1983 -1982 -1981 -1980 -1979 -1978 -1977 -1976 Columns 16 through 30 -1975 -1974 -1973 -1972 -1971 -1970 -1969 -1968 -1967 -1966 -1965 -1964 -1963 -1962 -1961 Columns 31 through 45 -1960 -1959 -1958 -1957 -1956 -1955 -1954 -1953 -1952 -1951 -1950 -1949 -1948 -1947 -1946 Columns 46 through 60 -1945 -1944 -1943 -1942 -1941 -1940 -1939 -1938 -1937 -1936 -1935 -1934 -1933 -1932 -1931 Columns 61 through 75 -1930 -1929 -1928 -1927 -1926 -1925 -1924 -1923 -1922 -1921 -1920 -1919 -1918 -1917 -1916 Columns 76 through 90 -1915 -1914 -1913 -1912 -1911 -1910 -1909 -1908 -1907 -1906 -1905 -1904 -1903 -1902 -1901 Columns 91 through 105 -1900 -1899 -1898 -1897 -1896 -1895 -1894 -1893 -1892 -1891 -1890 -1889 -1888 -1887 -1886 Columns 106 through 120 -1885 -1884 -1883 -1882 -1881 -1880 -1879 -1878 -1877 -1876 -1875 -1874 -1873 -1872 -1871 Columns 121 through 135 -1870 -1869 -1868 -1867 -1866 -1865 -1864 -1863 -1862 -1861 -1860 -1859 -1858 -1857 -1856 Columns 136 through 150 -1855 -1854 -1853 -1852 -1851 -1850 -1849 -1848 -1847 -1846 -1845 -1844 -1843 -1842 -1841 Columns 151 through 165 -1840 -1839 -1838 -1837 -1836 -1835 -1834 -1833 -1832 -1831 -1830 -1829 -1828 -1827 -1826 Columns 166 through 180 -1825 -1824 -1823 -1822 -1821 -1820 -1819 -1818 -1817 -1816 -1815 -1814 -1813 -1812 -1811 Columns 181 through 195 -1810 -1809 -1808 -1807 -1806 -1805 -1804 -1803 -1802 -1801 -1800 -1799 -1798 -1797 -1796 Columns 196 through 210 -1795 -1794 -1793 -1792 -1791 -1790 -1789 -1788 -1787 -1786 -1785 -1784 -1783 -1782 -1781 Columns 211 through 225 -1780 -1779 -1778 -1777 -1776 -1775 -1774 -1773 -1772 -1771 -1770 -1769 -1768 -1767 -1766 Columns 226 through 240 -1765 -1764 -1763 -1762 -1761 -1760 -1759 -1758 -1757 -1756 -1755 -1754 -1753 -1752 -1751 Columns 241 through 255 -1750 -1749 -1748 -1747 -1746 -1745 -1744 -1743 -1742 -1741 -1740 -1739 -1738 -1737 -1736 Columns 256 through 270 -1735 -1734 -1733 -1732 -1731 -1730 -1729 -1728 -1727 -1726 -1725 -1724 -1723 -1722 -1721 Columns 271 through 285 -1720 -1719 -1718 -1717 -1716 -1715 -1714 -1713 -1712 -1711 -1710 -1709 -1708 -1707 -1706 Columns 286 through 300 -1705 -1704 -1703 -1702 -1701 -1700 -1699 -1698 -1697 -1696 -1695 -1694 -1693 -1692 -1691 Columns 301 through 315 -1690 -1689 -1688 -1687 -1686 -1685 -1684 -1683 -1682 -1681 -1680 -1679 -1678 -1677 -1676 Columns 316 through 330 -1675 -1674 -1673 -1672 -1671 -1670 -1669 -1668 -1667 -1666 -1665 -1664 -1663 -1662 -1661 Columns 331 through 345 -1660 -1659 -1658 -1657 -1656 -1655 -1654 -1653 -1652 -1651 -1650 -1649 -1648 -1647 -1646 Columns 346 through 360 -1645 -1644 -1643 -1642 -1641 -1640 -1639 -1638 -1637 -1636 -1635 -1634 -1633 -1632 -1631 Columns 361 through 375 -1630 -1629 -1628 -1627 -1626 -1625 -1624 -1623 -1622 -1621 -1620 -1619 -1618 -1617 -1616 Columns 376 through 390 -1615 -1614 -1613 -1612 -1611 -1610 -1609 -1608 -1607 -1606 -1605 -1604 -1603 -1602 -1601 Columns 391 through 405 -1600 -1599 -1598 -1597 -1596 -1595 -1594 -1593 -1592 -1591 -1590 -1589 -1588 -1587 -1586 Columns 406 through 420 -1585 -1584 -1583 -1582 -1581 -1580 -1579 -1578 -1577 -1576 -1575 -1574 -1573 -1572 -1571 Columns 421 through 435 -1570 -1569 -1568 -1567 -1566 -1565 -1564 -1563 -1562 -1561 -1560 -1559 -1558 -1557 -1556 Columns 436 through 450 -1555 -1554 -1553 -1552 -1551 -1550 -1549 -1548 -1547 -1546 -1545 -1544 -1543 -1542 -1541 Columns 451 through 465 -1540 -1539 -1538 -1537 -1536 -1535 -1534 -1533 -1532 -1531 -1530 -1529 -1528 -1527 -1526 Columns 466 through 480 -1525 -1524 -1523 -1522 -1521 -1520 -1519 -1518 -1517 -1516 -1515 -1514 -1513 -1512 -1511 Columns 481 through 495 -1510 -1509 -1508 -1507 -1506 -1505 -1504 -1503 -1502 -1501 -1500 -1499 -1498 -1497 -1496 Columns 496 through 510 -1495 -1494 -1493 -1492 -1491 -1490 -1489 -1488 -1487 -1486 -1485 -1484 -1483 -1482 -1481 Columns 511 through 525 -1480 -1479 -1478 -1477 -1476 -1475 -1474 -1473 -1472 -1471 -1470 -1469 -1468 -1467 -1466 Columns 526 through 540 -1465 -1464 -1463 -1462 -1461 -1460 -1459 -1458 -1457 -1456 -1455 -1454 -1453 -1452 -1451 Columns 541 through 555 -1450 -1449 -1448 -1447 -1446 -1445 -1444 -1443 -1442 -1441 -1440 -1439 -1438 -1437 -1436 Columns 556 through 570 -1435 -1434 -1433 -1432 -1431 -1430 -1429 -1428 -1427 -1426 -1425 -1424 -1423 -1422 -1421 Columns 571 through 585 -1420 -1419 -1418 -1417 -1416 -1415 -1414 -1413 -1412 -1411 -1410 -1409 -1408 -1407 -1406 Columns 586 through 600 -1405 -1404 -1403 -1402 -1401 -1400 -1399 -1398 -1397 -1396 -1395 -1394 -1393 -1392 -1391 Columns 601 through 615 -1390 -1389 -1388 -1387 -1386 -1385 -1384 -1383 -1382 -1381 -1380 -1379 -1378 -1377 -1376 Columns 616 through 630 -1375 -1374 -1373 -1372 -1371 -1370 -1369 -1368 -1367 -1366 -1365 -1364 -1363 -1362 -1361 Columns 631 through 645 -1360 -1359 -1358 -1357 -1356 -1355 -1354 -1353 -1352 -1351 -1350 -1349 -1348 -1347 -1346 Columns 646 through 660 -1345 -1344 -1343 -1342 -1341 -1340 -1339 -1338 -1337 -1336 -1335 -1334 -1333 -1332 -1331 Columns 661 through 675 -1330 -1329 -1328 -1327 -1326 -1325 -1324 -1323 -1322 -1321 -1320 -1319 -1318 -1317 -1316 Columns 676 through 690 -1315 -1314 -1313 -1312 -1311 -1310 -1309 -1308 -1307 -1306 -1305 -1304 -1303 -1302 -1301 Columns 691 through 705 -1300 -1299 -1298 -1297 -1296 -1295 -1294 -1293 -1292 -1291 -1290 -1289 -1288 -1287 -1286 Columns 706 through 720 -1285 -1284 -1283 -1282 -1281 -1280 -1279 -1278 -1277 -1276 -1275 -127...

Output argument "errorposition" (and maybe others) not assigned during call to "find_error". Error in Test2 (line 8) [errorposition, truesequence] = find_error(errorsequence);