I would like to get a functional solution and nice display form for the following problem:
1. Example data
list = { {0, 1, 4, 8, 9, 1}, {0, 1, 4, 3, 3, 3}, {0, 8, 6, 1, 3, 2}, {0, 3, 1, 2, 3, 1}, {0, 2, 9, 2, 7, 3}, {0, 2, 1, 7, 2, 3} }; 2. Rules
- We start with a rectangular matrix with left-prepended zeros
- Traversing the first matrix row from left to right, we search the first minimum (1 at position 2), mark it red and put it in a bag.
- We continue with the 2nd row and find its first minimum not yet taken, which is 3 (1 is already in the bag).
- The lowest new number in the third row is 2.
- Arriving at the 4th row we find that all its distinct numbers are already in the bag. Therefore we mark the 0.
- Zero is the only element which can be marked more than once, which can be seen in the last row.
3. Expected result
4. Final display
The final display should also show the path, not just the red elements like in the above matrix. It could be for example a GridGraph like shown in kglr's answer to
How to find the shortest path going through some specified vertices
But I would also welcome other display forms.







