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: 2017/03/24 21:43; Updated at: 2017/03/24 23:25
The question is resolved.