Cody

# Problem 1089. Create a random vector of integers with given sum

Solution 2052592

Submitted on 9 Dec 2019
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)

montako = 4973 montako_oikeasti = 7 y = 1 26 26 26 26 26 26 26 26 4791

Assertion failed.

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)

montako = 997 montako_oikeasti = 1 y = 1 2 2 995

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)

montako = 98999 montako_oikeasti = 999 y = Columns 1 through 14 1 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 15 through 28 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 29 through 42 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 43 through 56 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 57 through 70 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 71 through 84 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 85 through 98 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 99 through 112 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 113 through 126 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 127 through 140 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 141 through 154 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 155 through 168 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 169 through 182 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 183 through 196 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 197 through 210 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 211 through 224 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 225 through 238 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 239 through 252 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 253 through 266 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 267 through 280 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 281 through 294 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 295 through 308 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 309 through 322 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 323 through 336 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 337 through 350 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 351 through 364 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 365 through 378 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 379 through 392 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 393 through 406 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 407 through 420 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 421 through 434 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 435 through 448 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 449 through 462 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 463 through 476 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 477 through 490 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 491 through 504 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 505 through 518 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 519 through 532 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 533 through 546 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 547 through 560 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 561 through 574 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 575 through 588 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 589 through 602 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 603 through 616 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 617 through 630 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 631 through 644 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 645 through 658 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 659 through 672 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 673 through 686 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 687 through 700 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 Columns 701 through 714 1000 1000 1000 1000 1000 1000 ...

Assertion failed.