Cody

Solution 2230050

Submitted on 23 Apr 2020 by Yuan
  • Size: 23
  • This is the leading solution.
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); 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

ans = 10 12 14 16 18 20 22 24 26 28 Idx = 1 ans = 10 12 14 16 18 20 22 24 26 28 Idx = 2 ans = 10 12 14 16 18 20 22 24 26 28 Idx = 3 ans = 10 12 14 16 18 20 22 24 26 28 Idx = 4 ans = 10 12 14 16 18 20 22 24 26 28 Idx = 5 ans = 10 12 14 16 18 20 22 24 26 28 Idx = 6 ans = 10 12 14 16 18 20 22 24 26 28 Idx = 7 ans = 10 12 14 16 18 20 22 24 26 28 Idx = 8 ans = 10 12 14 16 18 20 22 24 26 28 Idx = 9 ans = 10 12 14 16 18 20 22 24 26 28 Idx = 10

2   Pass
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

ans = Columns 1 through 14 6 14 22 30 38 46 54 62 70 78 86 94 102 110 Columns 15 through 28 118 126 134 142 150 158 166 174 182 190 198 206 214 222 Columns 29 through 42 230 238 246 254 262 270 278 286 294 302 310 318 326 334 Columns 43 through 56 342 350 358 366 374 382 390 398 406 414 422 430 438 446 Columns 57 through 70 454 462 470 478 486 494 502 510 518 526 534 542 550 558 Columns 71 through 84 566 574 582 590 598 606 614 622 630 638 646 654 662 670 Columns 85 through 98 678 686 694 702 710 718 726 734 742 750 758 766 774 782 Columns 99 through 112 790 798 806 814 822 830 838 846 854 862 870 878 886 894 Columns 113 through 126 902 910 918 926 934 942 950 958 966 974 982 990 998 1006 Columns 127 through 140 1014 1022 1030 1038 1046 1054 1062 1070 1078 1086 1094 1102 1110 1118 Columns 141 through 154 1126 1134 1142 1150 1158 1166 1174 1182 1190 1198 1206 1214 1222 1230 Columns 155 through 168 1238 1246 1254 1262 1270 1278 1286 1294 1302 1310 1318 1326 1334 1342 Columns 169 through 182 1350 1358 1366 1374 1382 1390 1398 1406 1414 1422 1430 1438 1446 1454 Columns 183 through 196 1462 1470 1478 1486 1494 1502 1510 1518 1526 1534 1542 1550 1558 1566 Columns 197 through 201 1574 1582 1590 1598 1606 Idx = 1 ans = Columns 1 through 14 6 14 22 30 38 46 54 62 70 78 86 94 102 110 Columns 15 through 28 118 126 134 142 150 158 166 174 182 190 198 206 214 222 Columns 29 through 42 230 238 246 254 262 270 278 286 294 302 310 318 326 334 Columns 43 through 56 342 350 358 366 374 382 390 398 406 414 422 430 438 446 Columns 57 through 70 454 462 470 478 486 494 502 510 518 526 534 542 550 558 Columns 71 through 84 566 574 582 590 598 606 614 622 630 638 646 654 662 670 Columns 85 through 98 678 686 694 702 710 718 726 734 742 750 758 766 774 782 Columns 99 through 112 790 798 806 814 822 830 838 846 854 862 870 878 886 894 Columns 113 through 126 902 910 918 926 934 942 950 958 966 974 982 990 998 1006 Columns 127 through 140 1014 1022 1030 1038 1046 1054 1062 1070 1078 1086 1094 1102 1110 1118 Columns 141 through 154 1126 1134 1142 1150 1158 1166 1174 1182 1190 1198 1206 1214 1222 1230 Columns 155 through 168 1238 1246 1254 1262 1270 1278 1286 1294 1302 1310 1318 1326 1334 1342 Columns 169 through 182 1350 1358 1366 1374 1382 1390 1398 1406 1414 1422 1430 1438 1446 1454 Columns 183 through 196 1462 1470 1478 1486 1494 1502 1510 1518 1526 1534 1542 1550 1558 1566 Columns 197 through 201 1574 1582 1590 1598 1606 Idx = 11 ans = Columns 1 through 14 6 14 22 30 38 46 54 62 70 78 86 94 102 110 Columns 15 through 28 118 126 134 142 150 158 166 174 182 190 198 206 214 222 Columns 29 through 42 230 238 246 254 262 270 278 286 294 302 310 318 326 334 Columns 43 through 56 342 350 358 366 374 382 390 398 406 414 422 430 438 446 Columns 57 through 70 454 462 470 478 486 494 502 510 518 526 534 542 550 558 Columns 71 through 84 566 574 582 590 598 606 614 622 630 638 646 654 662 670 Columns 85 through 98 678 686 694 702 710 718 726 734 742 750 758 766 774 782 Columns 99 through 112 790 798 806 814 822 830 838 846 854 862 870 878 886 894 Columns 113 through 126 902 910 918 926 934 942 950 958 966 974 982 990 998 1006 Columns 127 through 140 1014 1022 1030 1038 1046 1054 1062 1070 1078 1086 1094 1102 1110 1118 Columns 141 through 154 1126 1134 1142 1150 1158 1166 1174 1182 1190 1198 1206 1214 1222 1230 Columns 155 through 168 1238 1246 1254 1262 1270 1278 1286 1294 1302 1310 1318 1326 1334 1342 Columns 169 through 182 1350 1358 1366 1374 1382 1390 1398 1406 1414 1422 1430 1438 1446 1454 Columns 183 through 196 1462 1470 1478 1486 1494 1502 1510 1518 1526 1534 1542 1550 1558 1566 Columns 197 through 201 1574 1582 1590 1598 1606 Idx = 21 ans = Columns 1 through 14 6 14 22 30 38 46 54 62 70 78 86 94 102 110 Columns 15 through 28 118 126 134 142 150 158 166 174 182 190 198 206 214 222 Columns 29 through 42 230 238 246 254 262 270 278 286 294 302 310 318 326 334 Columns 43 through 56 342 350 358 366 374 382 390 398 406 414 422 430 438 446 Columns 57 through 70 454 462 470 478 486 494 502 510 518 526 534 542 550 558 Columns 71 through 84 566 574 582 590 598 606 614 622 630 638 646 654 662 670 Columns 85 through 98 678 686 694 702 710 718 726 734 742 750 758 766 774 782 Columns 99 through 112 790 798 806 ...