Cody

Solution 2230045

Submitted on 23 Apr 2020 by Yuan
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 = 5 -1 -7 -13 -19 -25 -31 -37 -43 -49 Idx = 1 ans = 5 -1 -7 -13 -19 -25 -31 -37 -43 -49 Idx = 2 ans = 5 -1 -7 -13 -19 -25 -31 -37 -43 -49 Idx = 3 ans = 5 -1 -7 -13 -19 -25 -31 -37 -43 -49 Idx = 4 ans = 5 -1 -7 -13 -19 -25 -31 -37 -43 -49 Idx = 5 ans = 5 -1 -7 -13 -19 -25 -31 -37 -43 -49 Idx = 6 ans = 5 -1 -7 -13 -19 -25 -31 -37 -43 -49 Idx = 7 ans = 5 -1 -7 -13 -19 -25 -31 -37 -43 -49 Idx = 8 ans = 5 -1 -7 -13 -19 -25 -31 -37 -43 -49 Idx = 9 ans = 5 -1 -7 -13 -19 -25 -31 -37 -43 -49 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 15 7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 Columns 16 through 30 97 103 109 115 121 127 133 139 145 151 157 163 169 175 181 Columns 31 through 45 187 193 199 205 211 217 223 229 235 241 247 253 259 265 271 Columns 46 through 60 277 283 289 295 301 307 313 319 325 331 337 343 349 355 361 Columns 61 through 75 367 373 379 385 391 397 403 409 415 421 427 433 439 445 451 Columns 76 through 90 457 463 469 475 481 487 493 499 505 511 517 523 529 535 541 Columns 91 through 105 547 553 559 565 571 577 583 589 595 601 607 613 619 625 631 Columns 106 through 120 637 643 649 655 661 667 673 679 685 691 697 703 709 715 721 Columns 121 through 135 727 733 739 745 751 757 763 769 775 781 787 793 799 805 811 Columns 136 through 150 817 823 829 835 841 847 853 859 865 871 877 883 889 895 901 Columns 151 through 165 907 913 919 925 931 937 943 949 955 961 967 973 979 985 991 Columns 166 through 180 997 1003 1009 1015 1021 1027 1033 1039 1045 1051 1057 1063 1069 1075 1081 Columns 181 through 195 1087 1093 1099 1105 1111 1117 1123 1129 1135 1141 1147 1153 1159 1165 1171 Columns 196 through 201 1177 1183 1189 1195 1201 1207 Idx = 1 ans = Columns 1 through 15 7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 Columns 16 through 30 97 103 109 115 121 127 133 139 145 151 157 163 169 175 181 Columns 31 through 45 187 193 199 205 211 217 223 229 235 241 247 253 259 265 271 Columns 46 through 60 277 283 289 295 301 307 313 319 325 331 337 343 349 355 361 Columns 61 through 75 367 373 379 385 391 397 403 409 415 421 427 433 439 445 451 Columns 76 through 90 457 463 469 475 481 487 493 499 505 511 517 523 529 535 541 Columns 91 through 105 547 553 559 565 571 577 583 589 595 601 607 613 619 625 631 Columns 106 through 120 637 643 649 655 661 667 673 679 685 691 697 703 709 715 721 Columns 121 through 135 727 733 739 745 751 757 763 769 775 781 787 793 799 805 811 Columns 136 through 150 817 823 829 835 841 847 853 859 865 871 877 883 889 895 901 Columns 151 through 165 907 913 919 925 931 937 943 949 955 961 967 973 979 985 991 Columns 166 through 180 997 1003 1009 1015 1021 1027 1033 1039 1045 1051 1057 1063 1069 1075 1081 Columns 181 through 195 1087 1093 1099 1105 1111 1117 1123 1129 1135 1141 1147 1153 1159 1165 1171 Columns 196 through 201 1177 1183 1189 1195 1201 1207 Idx = 11 ans = Columns 1 through 15 7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 Columns 16 through 30 97 103 109 115 121 127 133 139 145 151 157 163 169 175 181 Columns 31 through 45 187 193 199 205 211 217 223 229 235 241 247 253 259 265 271 Columns 46 through 60 277 283 289 295 301 307 313 319 325 331 337 343 349 355 361 Columns 61 through 75 367 373 379 385 391 397 403 409 415 421 427 433 439 445 451 Columns 76 through 90 457 463 469 475 481 487 493 499 505 511 517 523 529 535 541 Columns 91 through 105 547 553 559 565 571 577 583 589 595 601 607 613 619 625 631 Columns 106 through 120 637 643 649 655 661 667 673 679 685 691 697 703 709 715 721 Columns 121 through 135 727 733 739 745 751 757 763 769 775 781 787 793 799 805 811 Columns 136 through 150 817 823 829 835 841 847 853 859 865 871 877 883 889 895 901 Columns 151 through 165 907 913 919 925 931 937 943 949 955 961 967 973 979 985 991 Columns 166 through 180 997 1003 1009 1015 1021 1027 1033 1039 1045 1051 1057 1063 1069 1075 1081 Columns 181 through 195 1087 1093 1099 1105 1111 1117 1123 1129 1135 1141 1147 1153 1159 1165 1171 Columns 196 through 201 1177 1183 1189 1195 1201 1207 Idx = 21 ans = Columns 1 through 15 7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 Columns 16 through 30 97 103 109 115 121 127 133 139 145 151 157 163 169 175 181 Columns 31 through 45 187 193 199 205 211 217 223 229 235 241 247 253 259 265 271 Columns 46 through 60 277 283 289 295 301 307 313 319 325 331 337 343 349 355 361 Columns 61 through 75 367 373 379 385 391 397 403 409 415 421 427 433 439 445 451 Columns 76 through 90 457 463 469 475 481 487 493 499 505 511 517 523 529 535 541 Columns 91 through 105 547 553 559 565 571 577 583 589 595 601 607 613 619 625 631 Columns 106 through 120 637 643 ...

Suggested Problems

More from this Author9