Hi all,
I'm stuck with this problem trying to find an algorithm for it. I have a triangle like this:
1
1 2
1 2 3
1 2 3 4
I need to find all possible routes starting from the top of the triangle "1" till the bottom ,giving that I can only go left or right to the number.
For example the routes for the above triangle are:
1 1 1 1
1 1 1 2
1 1 2 2
1 2 2 2
1 2 2 3
1 2 3 3
1 2 3 4
what I did so far is implement the triangle in a two dimension array, and I did a for loop to get the following left or right number of each number of the array.
Please help I seem to be getting nowhere.
P.S :The triangle is supposed to be in a triangle shape but it gets messed up when I post it

.