# get a combination of unique paths for given pair of numbers

34 views (last 30 days)
ONKAR BHANDARE on 23 Oct 2020
Commented: ONKAR BHANDARE on 23 Oct 2020
I need to get combination of all unique paths. I have a path as follows:
107 111 354 371 326 375 145
pipe# 107 has 2 other pipes - 108 and 109
similarly, 354 has another 355
375 has 378 and 382
Desired output from [107/108/109], 111, [354 355], 371, 326, [375 378 382], 145 should be :
107 111 354 371 326 375 145
108 111 354 371 326 375 145
109 111 354 371 326 375 145
107 111 355 371 326 375 145
108 111 355 371 326 375 145
109 111 355 371 326 375 145
107 111 354 371 326 378 145
108 111 354 371 326 378 145
109 111 354 371 326 378 145
107 111 355 371 326 378 145
108 111 355 371 326 378 145
109 111 355 371 326 378 145
107 111 354 371 326 382 145
108 111 354 371 326 382 145
109 111 354 371 326 382 145
107 111 355 371 326 382 145
108 111 355 371 326 382 145
109 111 355 371 326 382 145
I would really appreciate if you could help me with the code or an idea. Thank you!!

Walter Roberson on 23 Oct 2020
This is easy to calculate using a code pattern that I call "odometer". Each cycle, move on to next valid entry in the last position, and when it reaches the maximum, "roll over" it and increment the second last... rolling it over as necessary. The general code pattern does not require that each position has the same number of possibilities.
ONKAR BHANDARE on 23 Oct 2020
Thanks a lot Walter! This helps a lot!

### Categories

Find more on Common Data Format in Help Center and File Exchange

R2020b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!