A homeless student who slept on friends' sofas while taking his A-levels has been accepted to study law at Cambridge University after achieving straight A*s.

Jacob Lewis, 22, achieved full marks in history and law and was awarded four A*s in total at Coleg y Cymoedd, in Aberdare.

He said he originally dropped out of school aged 17 but returned as a mature student after working in debt management for three years.

Jacob Lewis after getting his A-level results at Coleg y Cymoedd (Coleg y Cymoedd/Mike Hall Photography)

But moving back into education was a continuing struggle during a period where he was homeless and found himself “sofa surfing”, while attempting to balance study and work.

“It’s been a hard fight,” Mr Lewis said.

“At the start of this year I was working 24 hours a week to support my studies and make ends meet, I was barely eating.

“At one point I became homeless and had to start sofa surfing. Having a permanent home with my family wasn't an option.”

He said he sometimes spent 12 hours a day in the library at Coleg y Cymoedd, which supported him with its student hardship fund and temporarily housed him in a hotel.

Jacob will be studying at Cambridge University (Getty)

Mr Lewis is the first person in his family to go to university and said the “trying time” was worth it today.

“I haven’t got any firm career plans for after Cambridge, but I have a sincere commitment to try and make the world a better place with the advantages that elite education will give me,” he added.

Judith Evans, the principal at Coleg y Cymoedd, said the student was a “testament to the fact that hard work and commitment can really make dreams come true”.

“To secure a place at Cambridge to study law is an achievement in itself but when you consider the personal circumstances Jacob was battling at the time then it is truly astounding,” she added.

“We are so proud of him and are delighted to have been part of his journey.”

The overall pass rate for A-levels in Wales was 97.3 per cent this year – slightly lower than England and Northern Ireland.

By midnight, 409,410 people had been accepted on to university courses in the UK, the highest number on results day ever.