private function extractSnakes(array $v_save, $x, $y)
    {
        $snakes = array();
        for ($d = count($v_save) - 1; $x >= 0 && $y >= 0; $d--) {
            array_unshift($snakes, array($x, $y));

            $v = $v_save[$d];
            $k = $x - $y;

            if ($k === -$d || $k !== $d && $v[$k - 1] < $v[$k + 1]) {
                $k_prev = $k + 1;
            } else {
                $k_prev = $k - 1;
            }

            $x = $v[$k_prev];
            $y = $x - $k_prev;
        }

        return $snakes;
    }
private function extractSnakes(array $v_save, $x, $y)
    {
        $snakes = array();
        for ($d = count($v_save) - 1; $x >= 0 && $y >= 0; $d--) {
            array_unshift($snakes, array($x, $y));

            $v = $v_save[$d];
            $k = $x - $y;

            if ($k === -$d || $k !== $d && $v[$k - 1] < $v[$k + 1]) {
                $k_prev = $k + 1;
            } else {
                $k_prev = $k - 1;
            }

            $x = $v[$k_prev];
            $y = $x - $k_prev;
        }

        return $snakes;
    }
private function extractSnakes ( array $ v_save , $ x , $ y ) { $ snakes = array ( ) ; for ( $ d = count ( $ v_save ) - 1 ; $ x >= 0 && $ y >= 0 ; $ d -- ) { array_unshift ( $ snakes , array ( $ x , $ y ) ) ; $ v = $ v_save [ $ d ] ; $ k = $ x - $ y ; if ( $ k === - $ d || $ k !== $ d && $ v [ $ k - 1 ] < $ v [ $ k + 1 ] ) { $ k_prev = $ k + 1 ; } else { $ k_prev = $ k - 1 ; } $ x = $ v [ $ k_prev ] ; $ y = $ x - $ k_prev ; } return $ snakes ; }
Backtrack through the intermediate results to extract the "snakes" that
are visited on the chosen "D-path".

@param string[] $v_save Intermediate results
@param int      $x      End position
@param int      $y      End position

@return int[][]
Backtrack through the intermediate results to extract the snakes that are visited on the chosen D - path .