Cody

Problem 2534. Path of least resistance - Move all direction

Extension of the wonderful Problem 1049 (Path of Least Resistance).

A matrix is given as input. You have to take a tour starting from the top left corner to the bottom right corner of the matrix. You can move to any one of the adjacent 8 elements. Return only the sum of the elements in your path.

Example :

Input = [1 9 1 1
         9 1 9 1
         1 3 9 1
         9 9 8 1];
Output = 7;

Here, the least-sum path though the matrix is shown below with asterisk(*):

          [1* 9  1* 1*
           9  1* 9  1*
           1  3  9  1*
           9  9  8  1*];

Return only the sum of the elements along the path. I will add robust test cases time to time WITHOUT re-scoring existing solutions.

Solution Stats

47.83% Correct | 52.17% Incorrect
Last Solution submitted on Oct 06, 2019

Problem Comments