Cody

# Problem 1041. Find Index of maximum Value and maximum Value of a vector

Solution 1825466

Submitted on 24 May 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
seq=randi(5,1,10); seq_max = max(seq); seq_idx= find(seq==seq_max,1,'first'); [max_val, max_idx] = max_val_idx(seq); assert(isequal(max_val,seq_max)); assert(isequal(max_idx,seq_idx));

max_idx = 1 max_idx = 2 max_idx = 3 max_idx = 4

Assertion failed.

2   Fail
seq=rand(10); seq_max = max(seq(:)); seq_idx= find(seq==seq_max,1,'first'); [max_val, max_idx] = max_val_idx(seq); assert(isequal(max_val,seq_max)); assert(isequal(max_idx,seq_idx));

Output argument "max_idx" (and maybe others) not assigned during call to "max_val_idx". Error in Test2 (line 4) [max_val, max_idx] = max_val_idx(seq);

3   Fail
seq=randn(10); seq_max = max(seq(:)); seq_idx= find(seq==seq_max,1,'first'); [max_val, max_idx] = max_val_idx(seq); assert(isequal(max_val,seq_max)); assert(isequal(max_idx,seq_idx));

max_idx = 1

Assertion failed.

4   Fail
seq=randi(2^15,128,1); seq_max = max(seq(:)); seq_idx= find(seq==seq_max,1,'first'); [max_val, max_idx] = max_val_idx(seq); assert(isequal(max_val,seq_max)); assert(isequal(max_idx,seq_idx));

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

Assertion failed.