Cody

Solution 2091777

Submitted on 13 Jan 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
nocheat = isempty(regexp(evalc('type random_sequence'),'([^f]eval|regexprep|inline|str2func)')); m = 26; s = 5000; y = random_sequence(m,s); assert(isequal(sum(y),s) && abs(mean(y)-m/2)<m*sqrt(m/s)+1/2 && isequal(y,round(y)) && abs(std(y)-m/sqrt(12))*sqrt(s)/m<2.5 && nocheat)

Error using rand Size inputs must be integers. Error in random_sequence (line 2) y = m*rand(1,s/m) Error in Test1 (line 4) y = random_sequence(m,s);

2   Fail
nocheat = isempty(regexp(evalc('type random_sequence'),'([^f]eval|regexprep|inline|str2func)')); m = 2; s = 1000; y = random_sequence(m,s); assert(isequal(sum(y),s) && abs(mean(y)-m/2)<m*sqrt(m/s)+1/2 && isequal(y,round(y)) && abs(std(y)-m/sqrt(12))*sqrt(s)/m<2.5 && nocheat)

y = Columns 1 through 17 0.3417 0.7570 1.8371 0.5548 1.7692 1.3866 1.2904 1.2700 0.9817 0.7623 1.0998 0.2328 1.6239 1.3113 1.9638 1.8430 0.3671 Columns 18 through 34 0.5942 0.4488 1.9761 1.5393 0.0588 1.8371 1.0405 1.1641 1.7106 1.4528 1.4957 0.8556 0.8476 1.6668 1.1913 1.0191 1.4625 Columns 35 through 51 1.3984 1.8191 0.1062 0.8567 1.0325 0.1607 1.4668 1.4610 0.5478 1.8806 0.8110 1.1987 1.8038 0.0137 0.1305 1.7037 1.9009 Columns 52 through 68 0.0831 1.1835 0.2392 1.0613 1.4854 1.3054 1.6298 1.4021 1.9362 0.0963 0.7930 0.7165 0.3700 0.7750 0.6042 0.7365 1.0011 Columns 69 through 85 1.7460 0.5385 1.2597 1.1625 0.6963 0.7553 0.0517 1.3016 1.3802 0.3619 0.3257 1.3213 0.8129 1.1202 0.4391 0.1703 1.6250 Columns 86 through 102 1.6130 1.0960 1.2379 0.2514 1.6486 1.3357 0.3004 1.4257 0.5899 0.5648 1.4089 0.3055 1.8514 0.8922 1.5893 0.9356 0.5020 Columns 103 through 119 0.4546 0.2866 0.4248 0.7547 1.5505 1.4357 0.6140 1.3789 1.9696 1.2974 0.8767 0.7432 1.2823 1.4347 1.6692 1.0054 1.9939 Columns 120 through 136 1.6988 1.0292 1.5872 0.8826 1.1788 0.8383 0.4336 1.4809 1.7319 1.6274 0.0747 0.8535 0.0767 1.1195 0.4922 0.2550 1.8520 Columns 137 through 153 0.0376 0.6032 1.2660 1.6489 1.1533 1.8081 1.8210 1.5594 0.3680 0.5832 1.2522 1.6364 0.8807 1.1411 1.6140 0.7097 1.9547 Columns 154 through 170 1.0168 1.1783 1.3610 0.1608 0.0581 1.4940 0.5181 1.9774 1.1898 0.8824 1.9889 1.5193 0.3413 1.6889 0.3983 1.7155 1.6263 Columns 171 through 187 0.7889 0.8233 1.5762 0.4019 1.1938 0.0673 0.9986 1.6963 0.4242 0.1070 0.8555 0.3444 0.2176 1.3395 1.7836 0.4034 0.7432 Columns 188 through 204 1.4065 1.4861 1.4164 1.6586 1.5918 0.4558 1.0563 1.5701 0.4234 0.5664 0.3640 0.5269 0.4075 1.7575 0.1640 1.1506 0.1731 Columns 205 through 221 0.7046 0.9652 1.6790 1.4000 0.7526 1.6019 1.6598 0.9512 1.1485 0.2811 0.9159 0.9474 0.9446 1.9701 0.1717 1.8200 0.1181 Columns 222 through 238 1.6260 1.3092 1.0691 1.9232 1.5598 0.4838 0.2688 1.1660 0.8906 0.9065 1.9294 1.0014 1.4045 0.0981 0.9598 0.6573 0.9487 Columns 239 through 255 1.0730 0.1654 1.0502 0.2690 0.4697 1.4319 0.8432 0.0022 1.8139 0.4913 0.6593 0.5865 0.4582 1.3512 1.5267 1.0200 1.1908 Columns 256 through 272 1.8852 0.7043 1.9751 1.1560 1.6572 1.1058 0.7493 0.2176 0.8099 1.3748 1.4780 0.2318 0.3580 1.2927 1.6683 0.1265 0.8949 Columns 273 through 289 0.3390 1.0510 0.1904 0.4758 0.3883 0.4286 1.5793 0.4069 0.0794 0.1865 0.3832 1.2570 1.7487 1.1082 0.5903 0.0331 0.3197 Columns 290 through 306 1.9513 0.0616 1.6566 0.1199 0.7231 1.0578 1.0644 1.6285 0.0171 1.9945 0.4048 1.9007 0.2216 1.7365 1.7221 0.7388 0.9653 Columns 307 through 323 1.6703 0.6635 0.4709 1.0892 0.4964 1.7533 1.6940 1.8863 0.5864 0.5340 1.2096 1.3372 1.6114 1.9470 1.6447 0.8555 1.7642 Columns 324 through 340 1.4408 0.3895 0.0290 0.7786 1.2147 1.1183 1.3689 0.2464 1.5755 0.4587 1.8559 1.9522 0.8251 1.8898 0.6941 0.4783 1.6346 Columns 341 through 357 1.9575 1.7770 1.7725 0.9555 0.5321 1.8002 1.7516 1.2769 0.3114 1.8008 0.0419 1.4074 0.6340 0.1801 0.1884 1.5663 0.6555 Columns 358 through 374 1.4164 0.1014 0.5515 1.9974 0.6964 0.8592 0.0732 0.1308 1.2838 1.6912 0.8659 0.4314 1.5422 0.3318 1.4608 1.1303 1.2717 Columns 375 through 391 0.8856 0.3805 1.6803 0.4648 0.2399 1.1397 0.8677 0.6096 0.5646 0.8445 1.9169 1.0800 0.2380 1.7275 1.6088 1.1167 1.3777 Columns 392 through 408 0.8936 0.2497 0.9006 1.3556 1.5652 1.3861 1.7893 1.7936 0.2180 0.3285 1.7033 0.3199 0.0131 1.5265 1.4856 0.7996 1.4838 Columns 409 through 425 0.4477 0.9376 1.8636 1.6329 0.4667 1.0573 1.7094 0.8244 1.3237 1.9334 1.9871 0.8880 1.7396 1.8561 0.3312 1.0181 0.5602 Columns 426 through 442 1.1428 1.7959 1.2867 0.0964 0.1263 1.0117 0.4347 0.6883 1.4083 0.4703 1.5054 0.3434 1.4006 1.6442 1.3848 1.5860 0.6099 Columns 443 through 459 0.9210 0.3934 0.1205 0.9941 1.3413 1.1365 1.1339 0.2785 0.5222 1.4075 1.4848 0.3242 1.3155 0.3586 0.1940 0.0368 1.8858 Columns 460 through 476 0.4067 0.2024 0.3068 1.7663 1.2392 0.6309 0.3436 0.4826 1.5782 0.4125 0.9628 0.3761 1.6785 1.7307 1.0181 0.6095 0.9557 Columns 477 through 493 0.6104 1.8181 0.0605 1.4525 0.4669 0.3532 0.3745 0.7434 0.1672 1.8479 1.1968 1.2332 0.6257 0.4715 1.7878 1.1529 0.9031 Columns 494 through 500 1.6002 0.4219 0.8724 1.0076 0.2878 0.0313 0.4656

Assertion failed.

3   Fail
nocheat = isempty(regexp(evalc('type random_sequence'),'([^f]eval|regexprep|inline|str2func)')); m = 1000; s = 100000; y = random_sequence(m,s); assert(isequal(sum(y),s) && abs(mean(y)-m/2)<m*sqrt(m/s)+1/2 && isequal(y,round(y)) && abs(std(y)-m/sqrt(12))*sqrt(s^1/m^3)<1 && nocheat)

y = Columns 1 through 17 65.6261 966.5067 591.6997 204.8568 845.9272 623.1253 170.0189 138.8972 663.2881 288.9972 876.7435 339.7517 32.2005 254.1424 127.9217 418.5463 79.5836 Columns 18 through 34 933.0954 458.0513 985.6923 580.8880 205.4667 156.1273 42.8829 520.2476 504.4085 151.4041 305.3066 389.8715 229.2954 132.8068 314.4987 590.8000 449.9748 Columns 35 through 51 828.1047 839.1204 865.7259 757.0429 452.6529 9.1200 608.7572 897.5438 413.7589 873.9841 560.6549 93.0047 648.2951 684.0423 910.0858 694.9371 580.4919 Columns 52 through 68 197.4743 214.1069 648.9461 473.2487 472.3466 223.7631 559.2766 762.3558 282.8119 420.8744 495.7378 691.3463 461.3527 469.9483 328.4685 298.9079 392.3849 Columns 69 through 85 959.7690 554.7497 900.9376 393.1329 621.5825 757.7729 685.0614 300.3436 501.7473 633.1233 28.0234 579.4369 960.0995 171.8239 280.0137 395.3502 865.1597 Columns 86 through 100 876.5167 387.9732 443.9112 699.5443 639.7370 518.9593 547.6895 184.1881 796.5294 443.4214 677.6560 796.9070 201.1702 751.9178 825.3378

Assertion failed.