This is a solution to the mi5 coding puzzle at https://www.mi5.gov.uk/careers/opportunities/technology