Solution for problem 67 (triangle path II)