Cody

Solution 1398407

Submitted on 30 Dec 2017 by Francis Naldo
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
x = 1; y_correct = 0; assert(isequal(Recaman(x),y_correct))

ans = 0

2   Pass
x = 5; y_correct = [0 1 3 6 2]; assert(isequal(Recaman(x),y_correct))

ans = 0 1 3 6 2

3   Pass
x = 8; y_correct = [0 1 3 6 2 7 13 20]; assert(isequal(Recaman(x),y_correct))

ans = 0 1 3 6 2 7 13 20

4   Pass
x = 10; y_correct = [0 1 3 6 2 7 13 20 12 21]; assert(isequal(Recaman(x),y_correct))

ans = 0 1 3 6 2 7 13 20 12 21

5   Pass
x = 5e4; y = Recaman(x); assert(isequal(length(Recaman(x)),x)) assert(isequal(y(954),739)) assert(isequal(y(7589),17654)) assert(isequal(y(12345),18554))

ans = Columns 1 through 14 0 1 3 6 2 7 13 20 12 21 11 22 10 23 Columns 15 through 28 9 24 8 25 43 62 42 63 41 18 42 17 43 16 Columns 29 through 42 44 15 45 14 46 79 113 78 114 77 39 78 38 79 Columns 43 through 56 37 80 36 81 35 82 34 83 33 84 32 85 31 86 Columns 57 through 70 30 87 29 88 28 89 27 90 26 91 157 224 156 225 Columns 71 through 84 155 226 154 227 153 228 152 75 153 74 154 73 155 72 Columns 85 through 98 156 71 157 70 158 69 159 68 160 67 161 66 162 65 Columns 99 through 112 163 64 164 265 367 264 368 263 369 262 370 261 151 40 Columns 113 through 126 152 265 379 494 378 495 377 258 138 259 137 260 136 261 Columns 127 through 140 135 262 134 5 135 4 136 269 403 268 132 269 131 270 Columns 141 through 154 130 271 129 272 128 273 127 274 126 275 125 276 124 277 Columns 155 through 168 123 278 122 279 121 280 120 281 119 282 118 283 117 284 Columns 169 through 182 116 285 115 286 458 631 457 632 456 633 455 634 454 635 Columns 183 through 196 453 636 452 267 453 266 454 643 833 642 450 257 451 256 Columns 197 through 210 60 257 59 258 58 259 57 260 56 261 55 262 54 263 Columns 211 through 224 53 264 52 265 51 266 50 267 49 268 48 269 47 270 Columns 225 through 238 494 719 493 720 492 721 491 722 490 723 489 254 490 253 Columns 239 through 252 491 252 492 251 493 250 494 249 495 248 496 247 497 246 Columns 253 through 266 498 245 499 244 500 243 501 242 502 241 503 240 504 239 Columns 267 through 280 505 238 506 237 507 236 508 235 509 234 510 233 511 232 Columns 281 through 294 512 231 513 230 514 229 515 802 1090 801 1091 800 1092 799 Columns 295 through 308 1093 798 1094 797 1095 796 1096 795 1097 794 1098 793 487 180 Columns 309 through 322 488 179 489 178 490 177 491 176 492 175 493 174 494 173 Columns 323 through 336 495 172 496 171 497 170 498 169 499 168 500 167 501 166 Columns 337 through 350 502 165 503 842 1182 841 1183 840 1184 839 1185 838 1186 837 Columns 351 through 364 1187 836 484 837 483 838 482 839 481 840 480 841 479 842 Columns 365 through 378 478 843 477 110 478 109 479 108 480 107 481 106 482 105 Columns 379 through 392 483 104 484 103 485 102 486 101 487 100 488 99 489 98 Columns 393 through 406 490 97 491 96 492 95 493 94 494 93 495 92 496 901 Columns 407 through 420 1307 900 1308 899 1309 898 1310 897 1311 896 1312 895 1313 894 Columns 421 through 434 474 895 473 896 472 897 471 898 470 899 469 900 468 901 Columns 435 through 448 467 902 466 903 465 904 464 905 463 906 462 907 461 908 Columns 449 through 462 460 909 459 910 1362 1815 1361 1816 1360 1817 1359 1818 1358 1819 Columns 463 through 476 1357 1820 1356 891 425 892 424 893 423 894 422 895 421 896 Columns 477 through 490 420 897 419 898 418 899 417 900 416 901 415 902 414 903 Columns 491 through 504 413 904 412 905 411 906 410 907 409 908 408 909 407 910 Columns 505 through 518 406 911 405 912 404 913 1423 1934 1422 1935 1421 1936 1420 1937 Columns 519 through 532 1419 1938 1418 1939 1417 1940 1416 1941 1415 888 360 889 359 890 Columns 533 through 546 358 891 357 892 356 893 355 894 354 895 353 896 352 897 Columns 547 through 560 351 898 350 899 349 900 348 901 347 902 346 903 345 904 Columns 561 through 574 344 905 343 906 342 907 341 908 340 909 339 910 338 911 Columns 575 through 588 337 912 336 913 335 914 334 915 333 916 332 917 331 918 Columns 589 through 602 330 919 329 920 328 921 327 922 326 923 325 924 324 925 Columns 603 through 616 323 926 322 927 321 928 320 929 319 930 318 931 317 932 Columns 617 through 630 316 933 315 934 314 935 313 936 312 937 311 938 310 939 Columns 631 through 644 309 940 308 941 307 942 306 943 305 944 304 945 303 946 Columns 645 through 658 302 947 301 948 300 949 299 950 298 951 297 952 296 953 Columns 659 through 672 295 954 294 955 293 956 292 957 291 958 290 959 289 960 Columns 673 through 686 288 961 287 962 1638 2315 1637 2316 1636 2317 1635 2318 1634 2319 Columns 687 through 700 1633 2320 1632 2321 1631 2322 1630 2323 1629 2324 1628 2325 1627 2326 Columns 701 through 714 1626 2327 1625 2328 1624 2329 1623 2330 1622 2331 1621...

6   Pass
x = 1e5; y = Recaman(x); assert(isequal(length(Recaman(x)),x)) assert(isequal(y(1e4),8658)) assert(isequal(y(2e4),34358)) assert(isequal(y(3e4),92474)) assert(isequal(y(4e4),102344))

ans = Columns 1 through 14 0 1 3 6 2 7 13 20 12 21 11 22 10 23 Columns 15 through 28 9 24 8 25 43 62 42 63 41 18 42 17 43 16 Columns 29 through 42 44 15 45 14 46 79 113 78 114 77 39 78 38 79 Columns 43 through 56 37 80 36 81 35 82 34 83 33 84 32 85 31 86 Columns 57 through 70 30 87 29 88 28 89 27 90 26 91 157 224 156 225 Columns 71 through 84 155 226 154 227 153 228 152 75 153 74 154 73 155 72 Columns 85 through 98 156 71 157 70 158 69 159 68 160 67 161 66 162 65 Columns 99 through 112 163 64 164 265 367 264 368 263 369 262 370 261 151 40 Columns 113 through 126 152 265 379 494 378 495 377 258 138 259 137 260 136 261 Columns 127 through 140 135 262 134 5 135 4 136 269 403 268 132 269 131 270 Columns 141 through 154 130 271 129 272 128 273 127 274 126 275 125 276 124 277 Columns 155 through 168 123 278 122 279 121 280 120 281 119 282 118 283 117 284 Columns 169 through 182 116 285 115 286 458 631 457 632 456 633 455 634 454 635 Columns 183 through 196 453 636 452 267 453 266 454 643 833 642 450 257 451 256 Columns 197 through 210 60 257 59 258 58 259 57 260 56 261 55 262 54 263 Columns 211 through 224 53 264 52 265 51 266 50 267 49 268 48 269 47 270 Columns 225 through 238 494 719 493 720 492 721 491 722 490 723 489 254 490 253 Columns 239 through 252 491 252 492 251 493 250 494 249 495 248 496 247 497 246 Columns 253 through 266 498 245 499 244 500 243 501 242 502 241 503 240 504 239 Columns 267 through 280 505 238 506 237 507 236 508 235 509 234 510 233 511 232 Columns 281 through 294 512 231 513 230 514 229 515 802 1090 801 1091 800 1092 799 Columns 295 through 308 1093 798 1094 797 1095 796 1096 795 1097 794 1098 793 487 180 Columns 309 through 322 488 179 489 178 490 177 491 176 492 175 493 174 494 173 Columns 323 through 336 495 172 496 171 497 170 498 169 499 168 500 167 501 166 Columns 337 through 350 502 165 503 842 1182 841 1183 840 1184 839 1185 838 1186 837 Columns 351 through 364 1187 836 484 837 483 838 482 839 481 840 480 841 479 842 Columns 365 through 378 478 843 477 110 478 109 479 108 480 107 481 106 482 105 Columns 379 through 392 483 104 484 103 485 102 486 101 487 100 488 99 489 98 Columns 393 through 406 490 97 491 96 492 95 493 94 494 93 495 92 496 901 Columns 407 through 420 1307 900 1308 899 1309 898 1310 897 1311 896 1312 895 1313 894 Columns 421 through 434 474 895 473 896 472 897 471 898 470 899 469 900 468 901 Columns 435 through 448 467 902 466 903 465 904 464 905 463 906 462 907 461 908 Columns 449 through 462 460 909 459 910 1362 1815 1361 1816 1360 1817 1359 1818 1358 1819 Columns 463 through 476 1357 1820 1356 891 425 892 424 893 423 894 422 895 421 896 Columns 477 through 490 420 897 419 898 418 899 417 900 416 901 415 902 414 903 Columns 491 through 504 413 904 412 905 411 906 410 907 409 908 408 909 407 910 Columns 505 through 518 406 911 405 912 404 913 1423 1934 1422 1935 1421 1936 1420 1937 Columns 519 through 532 1419 1938 1418 1939 1417 1940 1416 1941 1415 888 360 889 359 890 Columns 533 through 546 358 891 357 892 356 893 355 894 354 895 353 896 352 897 Columns 547 through 560 351 898 350 899 349 900 348 901 347 902 346 903 345 904 Columns 561 through 574 344 905 343 906 342 907 341 908 340 909 339 910 338 911 Columns 575 through 588 337 912 336 913 335 914 334 915 333 916 332 917 331 918 Columns 589 through 602 330 919 329 920 328 921 327 922 326 923 325 924 324 925 Columns 603 through 616 323 926 322 927 321 928 320 929 319 930 318 931 317 932 Columns 617 through 630 316 933 315 934 314 935 313 936 312 937 311 938 310 939 Columns 631 through 644 309 940 308 941 307 942 306 943 305 944 304 945 303 946 Columns 645 through 658 302 947 301 948 300 949 299 950 298 951 297 952 296 953 Columns 659 through 672 295 954 294 955 293 956 292 957 291 958 290 959 289 960 Columns 673 through 686 288 961 287 962 1638 2315 1637 2316 1636 2317 1635 2318 1634 2319 Columns 687 through 700 1633 2320 1632 2321 1631 2322 1630 2323 1629 2324 1628 2325 1627 2326 Columns 701 through 714 1626 2327 1625 2328 1624 2329 1623 2330 1622 2331 1621...