16
1
Given one of the following as input:
AK,AR,AS,AZ,CA,CT,DC,FL,GA,IL,IN,IA,KS,KY,LA,MD,MI,MN,MS,NV,NH,NJ,NM,NY,NC,ND,MP,OH,OK,OR,PA,PR,RI,SC,TN,TX,UT,VT,VA,WA,WI
(with quotes)
"AK","AR","AS","AZ","CA","CT","DC","FL","GA","IL","IN","IA","KS","KY","LA","MD","MI","MN","MS","NV","NH","NJ","NM","NY","NC","ND","MP","OH","OK","OR","PA","PR","RI","SC","TN","TX","UT","VT","VA","WA","WI"
Generate and output a (uniformly) random license plate of the format matching the input. If there are multiple (comma separated) formats, use a (uniformly) random format:
AK, IA, MS, MP, VT: AAA 000
AS: 0000
AZ, GA, WA: AAA0000
AR, KS, KY, LA, ND, OR: 000 AAA
CA: 0AAA000
CT: AA-00000
DC: AA-0000
FL: AAA A00
IL: AA 00000
IN: 000A,000AA,000AAA,AAA000
MD: 0AA0000
MI: AAA 0000,0AA A00,AAA 000
MN: 000-AAA
NV: 00A-000
NH: 000 0000
NJ: A00-AAA
NM: 000-AAA,AAA-000
NY, NC, PA, TX, VA, WI: AAA-0000
OH: AAA 0000
OK: 000AAA
PR: AAA-000
RI: 000-000
SC: AAA 000,000 0AA
TN: A00-00A
UT: A00 0AA
Where A
means a random character in the uppercase alphabet minus IOQ
and 0
means a random single digit number (0
to 9
).
All information from Wikipedia. These (states) were all of the ones that I understood and that didn't have wonky rules.
This is code-golf, so shortest answer in bytes wins!
Sandbox; Related, but has several important differences, especially in license format and output specifics, not to mention that it is tagged [tag:popularity-contest] – Stephen – 2017-06-27T18:39:47.163
Wow, so THAT'S how they decide that... Interesting. – Magic Octopus Urn – 2017-06-27T18:52:47.870
@MagicOctopusUrn if you look at the Wikipedia article, it's quite interesting; I haven't implemented nearly all of what you would have to. Some have different stuff about what characters can be adjacent, about ending/beginning chars if your inspection date or county is x y or z, etc. It's crazy. Plus each state changes the pattern every ten years or so. – Stephen – 2017-06-27T18:54:07.630
I've always wondered what's up with LP numbers ever since I got pulled over when I got new plates. They said it was because the plates on my car had a number similar to that of a stolen vehicle. – Magic Octopus Urn – 2017-06-27T18:55:27.873
2@MagicOctopusUrn heh, about that, different states with the same format don't keep tabs on each other, so they can both issue the same number, and cops would have to look to see what state the plate is from – Stephen – 2017-06-27T18:56:24.567
1The size number space for each state varies. Do we 1) consider the combined number space for all states and uniformly pick from that (which will more heavily weight states with larger number spaces)? Or do we 2) first uniformly pick one of the 50 states and then uniformly pick a number from that state's number space (which will weight all states equally)? – Digital Trauma – 2017-06-27T19:18:43.527
@DigitalTrauma you uniformly use one of the formats to the right of the state name in the third code block. For example, for input
SC
, you should randomly generate eitherAAA 000
or000 0AA
. Is that (match input to format in list) unclear in my post? You're not randomly selecting a state, that's the input. You're randomly selecting which format to use, and which characters to include. – Stephen – 2017-06-27T19:21:08.3601Oh sorry I didn't read it properly. State is input. – Digital Trauma – 2017-06-27T19:25:10.357
1Ok, similar question for states that have multiple formats, e.g.
IN
. Do we uniformly pick a format (one of 000A, 000AA, 000AAA or AAA000), then pick a number from that format (each format weighted equally). Or do we consider the number space for all formats for that state and pick from that entire number space (larger formats weighted greater)? – Digital Trauma – 2017-06-27T20:22:33.493@DigitalTrauma first option (pick out of number of options of plates, not number of options of permutations), although in hindsight the second option might have been interesting – Stephen – 2017-06-27T20:27:15.990
2I think you left out "AR" and "OR" from the list of inputs, even though you describe their plate formats below. – Not a tree – 2017-06-28T03:03:50.423
1
@Notatree We were recently trained to remove "OR" from our state lists. ;-) As for "AR", I'm clueless...
– Arnauld – 2017-06-28T11:59:48.250@Notatree oops, thanks. It was late when I made this. – Stephen – 2017-06-28T12:31:18.163
@DLosc Sorry, a large block of states either don't have their exact license specs on Wikipedia, or have really weird rules based on inspection month or county or origin, that would make this challenge too complicated :P – Stephen – 2017-06-29T12:41:47.717
There is a quotation mark missing in the list of inputs after AR. – qazwsx – 2018-09-18T22:27:24.370
I had a standard
A00AA
Michigan plate not too long ago. Weird that Wikipedia doesn't list it. – Khuldraeseth na'Barya – 2019-08-23T16:13:05.293