Cody

# Problem 42802. Rolling maximums above a threshold

Solution 2663825

Submitted on 7 Jul 2020 by Nikolaos Nikolaou
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
m=magic(7);thresh=30; assert(isequal(rolling_max(m, thresh),5))

thresh = 38 thresh = 46 thresh = 47 thresh = 48 thresh = 49 y = 5

2   Pass
m=magic(14);thresh=200; assert(isequal(rolling_max(m, thresh),0));

y = 0

3   Pass
m=100:-2:0;thresh=50; assert(isequal(rolling_max(m, thresh),1));

thresh = 100 y = 1

4   Pass
m=reshape(1:1000,50,[]);thresh=ceil(200*rand); assert(isequal(rolling_max(m, thresh),1000-thresh));

thresh = 22 thresh = 23 thresh = 24 thresh = 25 thresh = 26 thresh = 27 thresh = 28 thresh = 29 thresh = 30 thresh = 31 thresh = 32 thresh = 33 thresh = 34 thresh = 35 thresh = 36 thresh = 37 thresh = 38 thresh = 39 thresh = 40 thresh = 41 thresh = 42 thresh = 43 thresh = 44 thresh = 45 thresh = 46 thresh = 47 thresh = 48 thresh = 49 thresh = 50 thresh = 51 thresh = 52 thresh = 53 thresh = 54 thresh = 55 thresh = 56 thresh = 57 thresh = 58 thresh = 59 thresh = 60 thresh = 61 thresh = 62 thresh = 63 thresh = 64 thresh = 65 thresh = 66 thresh = 67 thresh = 68 thresh = 69 thresh = 70 thresh = 71 thresh = 72 thresh = 73 thresh = 74 thresh = 75 thresh = 76 thresh = 77 thresh = 78 thresh = 79 thresh = 80 thresh = 81 thresh = 82 thresh = 83 thresh = 84 thresh = 85 thresh = 86 thresh = 87 thresh = 88 thresh = 89 thresh = 90 thresh = 91 thresh = 92 thresh = 93 thresh = 94 thresh = 95 thresh = 96 thresh = 97 thresh = 98 thresh = 99 thresh = 100 thresh = 101 thresh = 102 thresh = 103 thresh = 104 thresh = 105 thresh = 106 thresh = 107 thresh = 108 thresh = 109 thresh = 110 thresh = 111 thresh = 112 thresh = 113 thresh = 114 thresh = 115 thresh = 116 thresh = 117 thresh = 118 thresh = 119 thresh = 120 thresh = 121 thresh = 122 thresh = 123 thresh = 124 thresh = 125 thresh = 126 thresh = 127 thresh = 128 thresh = 129 thresh = 130 thresh = 131 thresh = 132 thresh = 133 thresh = 134 thresh = 135 thresh = 136 thresh = 137 thresh = 138 thresh = 139 thresh = 140 thresh = 141 thresh = 142 thresh = 143 thresh = 144 thresh = 145 thresh = 146 thresh = 147 thresh = 148 thresh = 149 thresh = 150 thresh = 151 thresh = 152 thresh = 153 thresh = 154 thresh = 155 thresh = 156 thresh = 157 thresh = 158 thresh = 159 thresh = 160 thresh = 161 thresh = 162 thresh = 163 thresh = 164 thresh = 165 thresh = 166 thresh = 167 thresh = 168 thresh = 169 thresh = 170 thresh = 171 thresh = 172 thresh = 173 thresh = 174 thresh = 175 thresh = 176 thresh = 177 thresh = 178 thresh = 179 thresh = 180 thresh = 181 thresh = 182 thresh = 183 thresh = 184 thresh = 185 thresh = 186 thresh = 187 thresh = 188 thresh = 189 thresh = 190 thresh = 191 thresh = 192 thresh = 193 thresh = 194 thresh = 195 thresh = 196 thresh = 197 thresh = 198 thresh = 199 thresh = 200 thresh = 201 thresh = 202 thresh = 203 thresh = 204 thresh = 205 thresh = 206 thresh = 207 thresh = 208 thresh = 209 thresh = 210 thresh = 211 thresh = 212 thresh = 213 thresh = 214 thresh = 215 thresh = 216 thresh = 217 thresh = 218 thresh = 219 thresh = 220 thresh = 221 thresh = 222 thresh = 223 thresh = 224 thresh = 225 thresh = 226 thresh = 227 thresh = 228 thresh = 229 thresh = 230 thresh = 231 thresh = 232 thresh = 233 thresh = 234 thresh = 235 thresh = 236 thresh = 237 thresh = 238 thresh = 239 thresh = 240 thresh = 241 thresh = 242 thresh = 243 thresh = 244 thresh = 245 thresh = 246 thresh = 247 thresh = 248 thresh = 249 thresh = 250 thresh = 251 thresh = 252 thresh = 253 thresh = 254 thresh = 255 thresh = 256 thresh = 257 thresh = 258 thresh = 259 thresh = 260 thresh = 261 thresh = 262 thresh = 263 thresh = 264 thresh = 265 thresh = 266 thresh = 267 thresh = 268 thresh = 269 thresh = 270 thresh = 271 thresh = 272 thresh = 273 thresh = 274 thresh = 275 thresh = 276 thresh = 277 thresh = 278 thresh = 279 thresh = 280 thresh = 281 thresh = 282 thresh = 283 thresh = 284 thresh = 285 thresh = 286 thresh = 287 thresh = 288 thresh = 289 thresh = 290 thresh = 291 thresh = 292 thresh = 293 thresh = 294 thresh = 295 thresh = 296 thresh = 297 thresh = 298 thresh = 299 thresh = 300 thresh = 301 thresh = 302 thresh = 303 thresh = 304 thresh = 305 thresh = 306 thresh = 307 thresh = 308 thresh = 309 thresh = 310 thresh = 311 thresh = 312 thresh = 313 thresh = 314 thresh = 315 thresh = 316 thresh = 317 thresh = 318 thresh = 319 thresh = 320 thresh = 321 thresh = 322 thresh = 323 thresh = 324 thresh = 325 thresh = 326 thresh = 327 thresh = 328 thresh = 329 thresh = 330 thresh = 331 thresh = 332 thresh = 333 thresh = 334 thresh = 335 thresh = 336 thresh = 337 thresh = 338 thresh = 339 thresh = 340 thresh = 341 thresh = 342 thresh = 343 thresh = 344 thresh = 345 thresh = 346 thresh = 347 thresh = 348 thresh = 349 thresh = 350 thresh = 351 thresh = 352 thresh = 353 thresh = 354 thresh = 355 thresh = 356 thresh = 357 thresh = 358 thresh = 359 thresh = 360 thresh = 361 thresh = 362 thresh = 363 thresh = 364 thresh = 365 thresh = 366 thresh = 367 thresh = 368 thresh = 369 thresh = 370 thresh = 371 thresh = 372 thresh = 373 thresh = 374 thresh = 375 thresh = 376 thresh = 377 thresh = 378 thresh = 379 thresh = 380 thresh = 381 thresh = 382 thresh = 383 thresh = 384 thresh = 385 thresh = 386 thresh = 387 thresh = 388 thresh = 389 thresh = 390 thresh = 391 thresh = 392 thresh = 393 thresh = 394 thresh = 395 thresh = 396 thresh = 397 thresh = 398 thresh = 399 thresh = 400 thresh = 401 thresh = 402 thresh = 403 thresh = 404 thresh = 405 thresh = 406 thresh = 407 thresh = 408 thresh = 409 thresh = 410 thresh = 411 thresh = 412 thresh = 413 thresh = 414 thresh = 415 thresh = 416 thresh = 417 thresh = 418 thresh = 419 thresh = 420 thresh = 421 thresh = 422 thresh = 423 thresh = 424 thresh = 425 thresh = 426 thresh = 427 thresh = 428 thresh = 429 thresh = 430 thresh = 431 thresh = 432 thresh = 433 thresh = 434 thresh = 435 thresh = 436 thresh = 437 thresh = 438 thresh = 439 thresh = 440 thresh = 441 thresh = 442 thresh = 443 thresh = 444 thresh = 445 thresh = 446 thresh = 447 thresh = 448 thresh = 449 thresh = 450 thresh = 451 thresh = 452 thresh = 453 thresh = 454 thresh = 455 thresh = 456 thresh = 457 thresh = 458 thresh = 459 thresh = 460 thresh = 461 thresh = 462 thresh = 463 thresh = 464 thresh = 465 thresh = 466 thresh = 467 thresh = 468 thresh = 469 thresh = 470 thresh = 471 thresh = 472 thresh = 473 thresh = 474 thresh = 475 thresh = 476 thresh = 477 thresh = 478 thresh = 479 thresh = 480 thresh = 481 thresh = 482 thresh = 483 thresh = 484 thresh = 485 thresh = 486 thresh = 487 thresh = 488 thresh = 489 thresh = 490 thresh = 491 thresh = 492 thresh = 493 thresh = 494 thresh = 495 thresh = 496 thresh = 497 thresh = 498 thresh = 499 thresh = 500 thresh = 501 thresh = 502 thresh = 503 thresh = 504 thresh = 505 thresh = 506 thresh = 507 thresh = 508 thresh = 509 thresh = 510 thresh = 511 thresh = 512 thresh = 513 thresh = 514 thresh = 515 thresh = 516 thresh = 517 thresh = 518 thresh = 519 thresh = 520 thresh = 521 thresh = 522 thresh = 523 thresh = 524 thresh = 525 thresh = 526 thresh = 527 thresh = 528 thresh = 529 thresh = 530 thresh = 531 thresh = 532 thresh = 533 thresh = 534 thresh = 535 thresh = 536 thresh = 537 thresh = 538 thresh = 539 thresh = 540 thresh = 541 thresh = 542 thresh = 543 thresh = 544 thresh = 545 thresh = 546 thresh = 547 thresh...

5   Pass
m=sort(rand(1,200));thresh=rand(); assert(isequal(rolling_max(m, thresh),sum(m>thresh)));

thresh = 0.7704 thresh = 0.7719 thresh = 0.7842 thresh = 0.7872 thresh = 0.7896 thresh = 0.7919 thresh = 0.7949 thresh = 0.8128 thresh = 0.8215 thresh = 0.8217 thresh = 0.8260 thresh = 0.8264 thresh = 0.8293 thresh = 0.8313 thresh = 0.8330 thresh = 0.8367 thresh = 0.8423 thresh = 0.8491 thresh = 0.8504 thresh = 0.8560 thresh = 0.8630 thresh = 0.8638 thresh = 0.8711 thresh = 0.8738 thresh = 0.8768 thresh = 0.8771 thresh = 0.8796 thresh = 0.8841 thresh = 0.8844 thresh = 0.8876 thresh = 0.8915 thresh = 0.8932 thresh = 0.8978 thresh = 0.9020 thresh = 0.9086 thresh = 0.9218 thresh = 0.9230 thresh = 0.9269 thresh = 0.9378 thresh = 0.9404 thresh = 0.9410 thresh = 0.9448 thresh = 0.9527 thresh = 0.9538 thresh = 0.9574 thresh = 0.9645 thresh = 0.9665 thresh = 0.9759 thresh = 0.9859 thresh = 0.9891 thresh = 0.9929 thresh = 0.9993 thresh = 0.9997 thresh = 0.9997 y = 54

6   Pass
m=[1 3 5 7 9 ; 1 3 5 7 9 ; 2 4 6 8 10; 2 4 6 8 10]; thresh=2; assert(isequal(rolling_max(m, thresh),8));

thresh = 3 thresh = 4 thresh = 5 thresh = 6 thresh = 7 thresh = 8 thresh = 9 thresh = 10 y = 8