Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Keep a list of the paths to each column in the row just reached with the highest score to that cell.</p> <p>You'd start (in your example), with the list</p> <pre><code>[([1],5), ([2],4), ([3],3), ([4],1)] </code></pre> <p>Then, when checking the next row, for each column, you pick the path with the highest score in the previous row that can reach that column, here, for the second row, in column 1 and 2, you'd pick the path ending in column 1 on the row above, and in column 3, you'd pick the path ending in column 2 in the row above, in column 4, the path ending in colum 3 in the previous row, so that would give you</p> <pre><code>[([1,1],15), ([1,2],7), ([2,3],5), ([3,4],3)] </code></pre> <p>for the third row, <code>[0,1,2,0]</code>, you'd again pick the path ending in column 1 for the first two columns, the path ending in column 2 for the third, and the path ending in column 3 for the fourth,</p> <pre><code>[([1,1,1],15), ([1,1,2],16), ([1,2,3],9), ([2,3,4],5)] </code></pre> <p>for the fourth row, <code>[2,3,4,20]</code>, you'd pick the path ending in column 2 for the first three columns, and the path ending in column 3 for the last,</p> <pre><code>[([1,1,2,1],18), ([1,1,2,2],19), ([1,1,2,3],20), ([1,2,3,4],29)] </code></pre> <p>Then, when you've reached the last row, you pick the path with the highest total.</p> <p>Why it works:</p> <p>Let the highest-scoring path end in column <code>c</code>. The part above the last column must be the highest scoring path ending in one of the columns <code>c-1, c, c+1</code> on the penultimate row, since column <code>c</code> in the last row can only be reached from those.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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