Modern British number plates (a.k.a. registration marks or license plates) use the format AANNXXX
where AA
is a "DVLA memory tag" (basically a location code), NN
is the age identifier, and XXX
is three random letters.
Your task is to, given a date, generate a random valid number plate with a date code matching the supplied date. Simplified from the actual implementation, this is how to generate them:
The memory tag will just be generated randomly:
- First letter: random from
ABCDEFGHKLMNOPRSVWY
(the alphabet, minusIJQTUXZ
) - Second letter: random from
ABCDEFGHJKLMNOPRSTUVWXY
(the alphabet, minusIQZ
)
- First letter: random from
The age identifier follows this pattern:
- 1st September 2001 - 28th February 2002:
51
- 1st March 2002 - 31st August 2002:
02
- September 2002 - February 2003:
52
- March 2003 - August 2003:
03
- ...
- March 2010 - August 2010:
10
- September 2010 - February 2011:
60
- March 2011 - August 2011:
11
- September 2011 - 29th February 2012:
61
- ...
- September 2020 - February 2021:
70
- ...
- September 2049 - February 2050:
99
- March 2050 - August 2050:
00
- September 2050 - February 2051:
50
- March 2051 - August 2051:
01
- 1st September 2001 - 28th February 2002:
The 3 random letters are picked from
ABCDEFGHJKLMNOPRSTUVWXYZ
(the alphabet, minusIQ
)
Rules
- You must output in uppercase with no spaces or dashes between letters. However, trailing newlines, or any other output from your language that is not easily suppressible, are allowed
- For the purposes of this challenge, "random" means picked pseudo-randomly with any distribution as long as all possibilities have a non-zero chance of occurring
- You may assume the date will always be in the range 1st September 2001 to 31st August 2051
- The date can be in any reasonable input format (for example, your language's native date object,
april 28 2021
,(28,4,21)
,1619615864
(a Unix epoch timestamp)) - You may ignore leap seconds, daylight savings time, and timezone issues (just assume the date is always in UTC)
- You may use any reasonable I/O method
- Standard loopholes are forbidden
- This is code-golf, so the shortest code in bytes wins
Test cases
These are to test the date conversion alone.
23rd September 2001 51
1st March 2006 06
29th February 2012 61
1st December 2021 71
11th October 2049 99
19th January 2051 50
March 2049 – Aug 2049 49 Sept 2049 – Feb 2050 99 March 2050 - Aug 2050 50 Sept 2050 - Feb 2051 00 March 2051 - Aug 2051 51
\$\endgroup\$