Note that there are some explanatory texts on larger screens.

plurals
  1. POShortest route of list of strings in python
    text
    copied!<p>I have a lists of lists and I am struggling to find the shortest route of the second elements of each. I can also convert it to a dictionary if that would be useful. What I was trying to do is to find the least amount of hops between the rows. To eventually create:</p> <p>But my brain just cant cope it at the moment to find a clear solution. Any ideas? And an overlap is not wanted unfortunately.</p> <pre><code> 186-151-155-145-144-185-155-151-145-144-186-151-155-145-144 [['1','186-151-155-145-144-####################186-151-155-145-144-'], ['2','186-151-################################186-151-'], ['3','186-####################################186-'], ['4','####151-155-145-144-########################151-155-145-144-'], ['5','####151-155-################################151-155-'], ['6',' ####151-####################151-############151-'], ['7','########155-############155-####################155-'], ['8','############145-144-############145-144-############145-144-'], ['9','############145-################145-################145-'], ['10','################144-################144-################144-'], ['11','####################185-'], ['12','################################145-144-186-'], ['13','########################################186-151-']] </code></pre> <p>After a wise comment, this might be a better data input:</p> <pre><code> [['1','186-151-155-145-144'], ['2','186-151'], ['3','186'], ['4','151-155-145-144'], ['5','151-155'], ['6','151'], ['7','155'], ['8','145-144'], ['9','145'], ['10','144'], ['11','185'], ['12','145-144-186'], ['13','186-151']] </code></pre> <p>And this needs to compile</p> <p>186-151-155-145-144-185-155-151-145-144-186-151-155-145-144</p> <p>In the most efficient way without overlap.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload