It’s a pub crawl that could last a lifetime but, thanks to the dedicated work of an international team of mathematicians who have plotted the shortest possible route to visit 25,000 boozers across the country, roaming ale drinkers of the UK now have a serious new challenge to consider.

Led by Professor William Cook from the University of Waterloo, Canada, the two-year project is an example of the “travelling salesman problem”, which aims to work out the shortest route between any number of locations before then returning to the starting point. It is described as one of the most intensively studied problems in computational mathematics.

Whose round is it this time? The tour in its entirety. Photograph: math.uwaterloo.ca

In this case, the team plotted the coordinates of 24,727 of the pubs listed on the comprehensive Pubs Galore website, before setting out to solve the problem of calculating the shortest possible route between them all.

The result is a 45,495km tour – that’s longer than the circumference of the Earth – laid out on an eye-boggling interactive Google Map, featuring a dizzying number of red pins, linked together by a never-ending blue line.

A close-up of the Brighton leg of the tour. Photograph: math.uwaterloo.ca

The route is circular, so travellers can start at any point, but on the list used by the team, calculations began at the The Green Shutters in Portland and ended at its neighbour, The Rodwell in Weymouth, a 6km walk away.

The average distance between each pub is an hour, but there are some dry patches; the longest is a 435km, 50-hour trip, from the Sango Sands Oasis in Durness to the Bells But & Ben in Shetland. However, the research team points out that this journey would include two ferry rides on which beer and other alcoholic drinks are available. Phew.

The Liverpool map with its red pins. Photograph: math.uwaterloo.ca

Pubs aside, the project represents the largest road-distance travelling salesman problem ever solved to date, with 100 times more stops than any previous projects.

As Cook says, the UK pub problem was used “as a means for developing and testing general-purpose optimisation methods, which have wide applications in science, industry and commerce”.

He adds: “We did not set out to improve the lot of a wandering pub aficionado.”