“Good puzzle would be cross Dublin without passing a pub,” according to Leopold Bloom, the main character of James Joyce’s Ulysses.

Just in time for Bloomsday, an Irish computer programmer thinks he’s cracked one of Dublin’s oldest mazes.

Rory McCann plotted a course through the city from the North Circular Road at Blackhorse Avenue to the canal at Baggot Street, which he says avoids every pub, even if it does require a detour through a museum and a park.

In a city famous for its public houses, Mr McCann set himself a few rules: “cross Dublin” required moving from north to south, and from east to west, roughly within the boundaries of the city’s canals.

“It was something I’d heard about, like most Dubliners, and it was an interesting idea,” Mr McCann said.

The UCD graduate used pub locations from OpenStreetMap, an online editable map, and designed a piece of computer code that ignored any routes across the city within 35 metres away from anywhere marked as a “pub”.

The result is a winding route through the city, around the outside (or through) Arbour Hill cemetery and cuts across the National Museum at Collins Barracks. At more than one point a trip around a block or down some narrow lanes is essential.

The Irish Times tested the route yesterday and found it accurate, despite a few close shaves.

The route takes the liberty of passing a few hotels. On the quays, just after passing James Joyce House on Usher’s Island, the route passes the now-closed Noel Leonard’s pub, and on Harcourt Street, Club Conradh na Gaeilge, a private club for Irish speakers with a bar in the basement.

Cutting across Iveagh Gardens, a park only open until 6pm, is essential to avoid the busy nightspots on Harcourt Street.

The route will take Dubliners down many streets they may not be familiar with, from the terraced housing on Murtagh Road on the northside to the abandoned Iveagh Market on Lamb’s Alley -an equally pub-less alternative to nearby Back Lane.

Mr McCann’s first version of the route passed two pubs, which readers on his blog quickly pointed out and he corrected them in time for Bloomsday. Some commentators argued that bars inside hotels should be counted, but Mr McCann disagreed.

At the very least, his efforts have offered a possible and inventive solution to an 89-year-old brainteaser.

“It’s something that a lot of people have been wondering about in Dublin, and a lot of people have been cynically pointing out I’ve ruined a great pub conversation,” Mr McCann said.