Engineers had to overcome challenging terrain and devised a narrow-gauge railway that could navigate the steep hills and sharp curves.