The map goddess @AngharadStone posed an interesting poser on Twitter last night.

@AngharadStone Good question. Do you mean the full postcode or just the first part? B, BB, DD, E, G, LL, M, N, NN, S, SS, W.

— BX Postcode Area (@BXpostcodearea) December 31, 2016

It seemed like an interesting problem, so I thought I’d give it a go.

The full definition is a fully palindromic postcode (across the space) that is also currently in use and valid.

My first thought was to start with a full list of postcodes from Doogal, and then prune them down – but my computer and excel wasn’t quite up to dealing with that many records.

Instead I wondered if I could build up to see how many possible palindromic postcodes there might be, and then see how many of them are valid.

I found a list of postcode districts on the Doogal downloads page. This is the outbound (GU1 1ED) and the first part of the inbound postcode (GU1 1ED). It struck me that there are only a very few districts which could even support a palindromic postcode:

- If the district is 5 digits long, the outbound and inbound digit have to be the same: GU1 1UG?
- If the district is 6 digits long, the first digit of the outbound, and the inbound digit have to be the same (GU10 1UG?). Also if the district is six digits long, then the space has to be ignored in the palindromicness (but that is fairly normal in well known palindromes like Madam I’m Adam).

These two criteria then allowed me to make a full list of all the possible (but not valid) postcodes.

There were 682 “five digit sector” possible postcodes, and a further 578 “six digit sector” possible postcodes. I can then construct what those postcodes would look like.

I then discovered that Doogal also has a page that can tell you how many postcodes are valid: https://www.doogal.co.uk/MultiplePostcodes.php

WOOHOO!

I can exclusively reveal there are (drum roll please)… 165 six digit valid palindromic postcodes and 167 seven digit valid palindromic postcodes – a total of 332 palindromic postcodes.

You can see the full list in this google document:

https://docs.google.com/spreadsheets/d/1qfI1QJIcPj2EeIBaLqnXTPqXgxCMVz8kK6MgWbKSShM/edit?usp=sharing

RobinAs the originator of the PPC (Palindromic Postcode Challenge), I thought I should let you know that I’ve finally finished and tested my method of identifying PPs using a RegEx expression…because Excel, SQL and anything else would just be too easy.

The answer is simply ([A-Z])([A-Z])([0-9])([0-Z])? ?\3\2\1

It works with both 6 and 7 character postcodes, including the funny London ones with the extra letter on the outbound postcode (of which the only palindromic one is SW1P 1WS).

Actually, when I tested it, it only found 328 matches, which I’m putting down to an out of date dataset.