Exercise 3 solution (Python) import math def split_ref(ref): """Return (line_e, tenth_e, line_n, tenth_n) from a six-figure string.""" if len(ref) != 6 or not ref.isdigit(): raise ValueError("need exactly six digits") easting, northing = ref[:3], ref[3:] return easting[:2], int(easting[2]), northing[:2], int(northing[2]) def to_metres(ref): """Position in metres from the grid origin, 1 km lines and 100 m tenths.""" le, te, ln, tn = split_ref(ref) return int(le) * 1000 + te * 100, int(ln) * 1000 + tn * 100 def distance_m(ref_a, ref_b): ea, na = to_metres(ref_a) eb, nb = to_metres(ref_b) return math.hypot(eb - ea, nb - na) print(split_ref("346723")) # ('34', 6, '72', 3) print(split_ref("351698")) # ('35', 1, '69', 8) print(distance_m("346723", "351698")) # about 2,550 m Check by hand for the test pair: 346723 -> easting 34,600 m, northing 72,300 m 351698 -> easting 35,100 m, northing 69,800 m difference: 500 m east, 2,500 m south straight line = sqrt(500^2 + 2500^2) = about 2,550 m The program and the hand check agree: about 2,550 m.