A GCHQ backed contest helping teachers to train schoolchildren as the next generation of cyber spies finished this week in Cheltenham, home of the agency’s famous doughnut headquarters.

Hosted by the Cheltenham Science Festival and Cheltenham College, the Cyber Games 2.0 asked students aged between 14 and 17 to break into an encoded system in order to free hostages, with recruiters from GCHQ attending the final ceremony.

James Jackson, programme leader for computing at the Grimsby Institute, whose pupils won the contest, said: "Most of our learners are more familiar with the hardware side of computing so the code-breaking challenges in the morning were something new, but they did great and took a lot from it."

The final was preceded by a nationwide programme sponsored by BT, Motorola and Bletchley Park that taught children from 720 schools to crack codes and build ciphers for encrypting messages and files.

Security professionals are often drawn from the informal ranks of the hacking community, with some of the industry’s most prominent members being reformed criminals, but the government has been keen to teach more children to programme as part of the Year of Code campaign.

Francis Maude, minister for cabinet office with responsibility for the UK’s cyber security, said the competition "helps show young people that cyber security can be a great career for school children to aspire to".

"In funding this innovative and exciting Cyber Games, we aim to help these talented teams take their aptitude for code-cracking into their working lives and consider careers in cyber security," he added.

Prizes for the finalists included programmable robots Lego Mindstorm and Robosapien, as well as Raspberry Pi, a credit card sized computer used to teach beginners to programme.