Cody

Problem 2561. expand intervals vol.3

Solution 1928703

Submitted on 10 Sep 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   Pass
bounds = [1 5 3 9 24 32]; elements = [1 2 3 4 5 6 7 8 9 24 25 26 27 28 29 30 31 32]; assert(isequal(ExpandIntervals(bounds),elements))

elements = 1 2 3 4 5 6 7 8 9 24 25 26 27 28 29 30 31 32

2   Fail
bounds = [5 1 3 9 32 24]; elements = [1 2 3 4 5 6 7 8 9 24 25 26 27 28 29 30 31 32]; assert(isequal(ExpandIntervals(bounds),elements))

elements = 3 4 5 6 7 8 9

Assertion failed.

3   Pass
bounds = [11 11 9 9]; elements = [9 11]; assert(isequal(ExpandIntervals(bounds),elements))

elements = 9 11

4   Fail
bounds = [200 400 300 100]; elements = [100:400]; assert(isequal(ExpandIntervals(bounds),elements))

elements = Columns 1 through 30 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 Columns 31 through 60 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 Columns 61 through 90 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 Columns 91 through 120 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 Columns 121 through 150 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 Columns 151 through 180 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 Columns 181 through 201 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400

Assertion failed.

5   Pass
temp = [-11:1.1:9; -9:9.5]; bounds = temp(:)'; elements = -11:9; assert(isequal(ExpandIntervals(bounds),elements))

elements = -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9

6   Fail
temp = [-11:1.21:11; -8.7:10]; bounds = temp(:)'; elements = [-11:0, 7:10]; assert(isequal(ExpandIntervals(bounds),elements))

elements = -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0

Assertion failed.

7   Pass
temp = [-11:2.599:9; -9:2.601:11]; bounds = temp(:)'; elements = [-11:-7, -5:-2, 0:6, 8:9]; assert(isequal(ExpandIntervals(bounds),elements))

elements = -11 -10 -9 -8 -7 -5 -4 -3 -2 0 1 2 3 4 5 6 8 9

8   Fail
bounds = [-10.8 10.9]; elements = -10:10; assert(isequal(ExpandIntervals(bounds),elements))

elements = Columns 1 through 18 -10.8000 -9.8000 -8.8000 -7.8000 -6.8000 -5.8000 -4.8000 -3.8000 -2.8000 -1.8000 -0.8000 0.2000 1.2000 2.2000 3.2000 4.2000 5.2000 6.2000 Columns 19 through 22 7.2000 8.2000 9.2000 10.2000

Assertion failed.

9   Fail
bounds = [10.8 -10.9]; elements = -10:10; assert(isequal(ExpandIntervals(bounds),elements))

elements = 1×0 empty double row vector

Assertion failed.