An Irish code-breaker, along with two others, has proved he is almost a match for the UK's national intelligence and security agency by winning its Christmas card cryptography challenge.

The winners, all men, battled through five rounds and beat 600,000 people to come the closest to fully solving the series of challenges set by director of GCHQ Robert Hannigan in his Christmas card.

David McBryan from Dublin said the possibility of winning was "driving him along" as he attempted to outsmart the GCHQ cryptographers.

The 41-year-old, who now lives in Edinburgh, said: "I thought I had solved it, but a news report came out a few days ago saying nobody had ... so I went back and had another look and figured out what I missed, but I was too late at that point.

"But it seems that everyone else missed it as well and I was joint closest. It was challenging - a very well-constructed set of puzzles, I'd recommend it to anyone actually. It's enjoyable but it's tough."

Mr McBryan, a former Fifteen to One game show winner who now writes questions for the show, studied maths and artificial intelligence in college.

He said "logical rigorous thinking" was needed to be a good puzzle-solver but that "most of all it's got to be just the experience of doing puzzles - the more you do the better you'll get at it".

The compendium of word and number puzzles took a team of eight GCHQ cryptographers two months to compile, and included a mix of past and fresh challenges - with plenty of hidden material.

The first stage was a grid-shading exercise which, when completed, revealed a scannable QR bar code to direct people to the next part.

Puzzlers then had to work out URLs and IP addresses through solving a series of clues until they reached the final stage.

Mr McBryan said: "Once you got through there's no confirmation whether you're on the right track or whether you got the right set of answers and that's one of the most frustrating aspects of it. So you need to be fairly obsessive to keep plugging away at it and trying different things.

"For a long time after I got all the solutions I was still looking for more because you've got no idea if you've got it all."

He added he wanted to "thank whoever the compilers are for coming up with such a great set of puzzles and possibly damn them for the frustration of not letting us know when we'd finished".

Thirty thousand people made it through to the final stage and 550 of those submitted answers.

Of the answers, six were considered "complete" by the team of cryptographers, who chose the final three winners based on the quality of their reasoning.

GCHQ denied that the puzzle was an elaborate ploy to recruit fresh talent to its ranks, but said the winners, like anyone else, were "welcome to apply" for jobs.

One of its cryptographers, whose identity cannot be revealed, said the team initially worried it would be too hard but added it was "very gratifying" that people had got so far.

He said: "I think we really didn't know whether it would be half a dozen people having a go so it was really difficult to judge how hard to make it.

"In fact when tens of thousands, maybe hundreds of thousands of people were actually looking at it we were really surprised."

He added he was sure Bletchley Park code-breaker Alan Turing would have been able to solve the challenge.

Each winner will receive a GCHQ paperweight, pen and signed copy of the book Alan Turing Decoded, written by Mr Turing's nephew Dermot Turing.

The full solution was published on GCHQ's website.