Cody

# Problem 2800. arithmetic progression

Solution 3919713

Submitted on 30 Nov 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

e = -12 -8 -18 -28 -38 -48 -58 -68 -78 -88 v = 4 -10 -10 -10 -10 -10 -10 -10 -10 a = -10 o = -12 idx = 1 errorposition = 1 truesequence = -12 -22 -32 -42 -52 -62 -72 -82 -92 -102

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

e = Columns 1 through 14 -31 11 19 27 35 43 51 59 67 75 83 91 99 107 Columns 15 through 28 115 123 131 139 147 155 163 171 179 187 195 203 211 219 Columns 29 through 42 227 235 243 251 259 267 275 283 291 299 307 315 323 331 Columns 43 through 56 339 347 355 363 371 379 387 395 403 411 419 427 435 443 Columns 57 through 70 451 459 467 475 483 491 499 507 515 523 531 539 547 555 Columns 71 through 84 563 571 579 587 595 603 611 619 627 635 643 651 659 667 Columns 85 through 98 675 683 691 699 707 715 723 731 739 747 755 763 771 779 Columns 99 through 112 787 795 803 811 819 827 835 843 851 859 867 875 883 891 Columns 113 through 126 899 907 915 923 931 939 947 955 963 971 979 987 995 1003 Columns 127 through 140 1011 1019 1027 1035 1043 1051 1059 1067 1075 1083 1091 1099 1107 1115 Columns 141 through 154 1123 1131 1139 1147 1155 1163 1171 1179 1187 1195 1203 1211 1219 1227 Columns 155 through 168 1235 1243 1251 1259 1267 1275 1283 1291 1299 1307 1315 1323 1331 1339 Columns 169 through 182 1347 1355 1363 1371 1379 1387 1395 1403 1411 1419 1427 1435 1443 1451 Columns 183 through 196 1459 1467 1475 1483 1491 1499 1507 1515 1523 1531 1539 1547 1555 1563 Columns 197 through 201 1571 1579 1587 1595 1603 v = Columns 1 through 29 42 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 Columns 30 through 58 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 Columns 59 through 87 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 Columns 88 through 116 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 Columns 117 through 145 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 Columns 146 through 174 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 Columns 175 through 200 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 a = 8 o = -31 idx = 1 errorposition = 1 truesequence = Columns 1 through 14 -31 -23 -15 -7 1 9 17 25 33 41 49 57 65 73 Columns 15 through 28 81 89 97 105 113 121 129 137 145 153 161 169 177 185 Columns 29 through 42 193 201 209 217 225 233 241 249 257 265 273 281 289 297 Columns 43 through 56 305 313 321 329 337 345 353 361 369 377 385 393 401 409 Columns 57 through 70 417 425 433 441 449 457 465 473 481 489 497 505 513 521 Columns 71 through 84 529 537 545 553 561 569 577 585 593 601 609 617 625 633 Columns 85 through 98 641 649 657 665 673 681 689 697 705 713 721 729 737 745 Columns 99 through 112 753 761 769 777 785 793 801 809 817 825 833 841 849 857 Columns 113 through 126 865 873 881 889 897 905 913 921 929 937 945 953 961 969 Columns 127 through 140 977 985 993 1001 1009 1017 1025 1033 1041 1049 1057 1065 1073 1081 Columns 141 through 154 1089 1097 1105 1113 1121 1129 1137 1145 1153 1161 1169 1177 1185 1193 Columns 155 through 168 1201 1209 1217 1225 1233 1241 1249 1257 1265 1273 1281 1289 1297 1305 Columns 169 through 182 1313 1321 1329 1337 1345 1353 1361 1369 1377 1385 1393 1401 1409 1417 Columns 183 through 196 1425 1433 1441 1449 1457 1465 1473 1481 1489 1497 1505 1513 1521 1529 Columns 197 through 201 1537 1545 1553 1561 1569

failed test 2 at position 1

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!