'How do i go through all possible sequences of a sequenc of numbers?
i think i got a simple problem, i just can not wrap my head around it.
Lets say i got an Array, with integers, representing IDs. (1, 2, 3, 4) in this order. I am looking for a way, to go through all possible sequences and perform a task afterwards. All IDs have an timelength behind them. If i am correct, there should be 24 possibilities. So i would like to start with checking 1234, and then see the next possibility. How can i get the loop/loops to go through all 24 possibilities? So i need to find and work immediately with the sequence, as i want to compere those. (Later will be with 6 numbers, so 720 possibilities, but procedure should be the same, so solving for 24 would be enough. Heck even for 3 with 6 possibilities would help a lot.)
1234 1243 1423 1432
and so on, no duplicates.
For an array with 6 numbers there should be 720? I tried loops within loops but i am stuck. My problem is, i know exactly what to do, on paper. But i have no clue, how to "tell the computer" to follow my logic.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
