I don't understand why the second example result == 26. Can you show the path?
In particular: when you say "must go over every mountaintop" -- does that mean that the path has to touch the highest point on every mountain? In that case I would think that the shortest path for the example would be 20:
'000000001110'
'011100002310'
'012100002220'
'011100000000'
'XXX00XXXX110'
'01X10X00XXXX'
'01XXXX002XXX'
'01110000000X'
Created at: March 24, 2017, 9:43 p.m.; Updated at: March 24, 2017, 11:25 p.m.
The question is resolved.