California License Plates Part 3
This story is totally unnecessary, but I will show the general form of a formula going from sequence number to license plate and vice-versa.
Defining the Alphabet
Similarly to what we did for the letter sequence in part 1, we need to correspond each character with a zero-indexed numeric value. For each character in the license plate, there is a corresponding "alphabet." This may not necessarily be "A-Z" or "0-9". In fact, it could contain a subset of letters and numbers, not even in order! This is a very weird, but valid alphabet containing 15 possible characters, let's call it "alphabet #1", or \(A_{1}\):
Character | Value |
---|---|
A |
\(0\) |
B |
\(1\) |
C |
\(2\) |
1 |
\(3\) |
2 |
\(4\) |
3 |
\(5\) |
D |
\(6\) |
7 |
\(7\) |
M |
\(8\) |
U |
\(9\) |
X |
\(10\) |
8 |
\(11\) |
. |
\(12\) |
Y |
\(13\) |
Z |
\(14\) |
Notice that characters can be anything, including punctuation. Some license plates might not allow this, but a guy can dream. As another example, let's define a shorter alphabet with only 5 characters, and call it "alphabet #2", or \(A_{2}\):
Character | Value |
---|---|
5 |
\(0\) |
4 |
\(1\) |
: |
\(2\) |
N |
\(3\) |
9 |
\(4\) |
Defining the Pattern
Okay, now that we have a few alphabets defined, we can define our license plate pattern. Let's keep things short and say we have a 4-character license plate using this pattern, with the outer 2 characters coming from "alphabet #1" and the inner 2 characters from "alphabet #2":
Here's how we could determine the total number of license plates in supply \(C\):
Getting the Sequence Number
So far, pretty simple. Now what about going from the license plate to the sequence number \(N\), where \(C_{i}\) is the character at position \(i\)? This also depends which digit position \(i\) is our least significant vs. our most significant digit. For this example, let's say that our digit significance is as follows:
This means the character in the 3rd position is the most significant (imagine "thousands-place"), the second position in "hundreds-place", last digit in "tens-place", and the first digit in the "ones-place". Using this knowledge we can start to build out our formula starting with the least significant digit:
This formula can be simplified and rearranged, plugging in the counts for our alphabets.
So, for a license plate 14:Y
(remember to follow the pattern rules, using only characters from the right alphabets) what is the sequence number? First, lets convert each character to it's corresponding value.
1
(from alphabet #1) = \(3\)4
(from alphabet #2) = \(1\):
(from alphabet #2) = \(2\)Y
(from alphabet #2) = \(13\)
All we need to do now is plug and chug.
As a quick sanity check: \((N=2673)<(C=5625)\), our sequence number is less than the count, so we are good! You know what's next!
Getting the Plate
Problem: You go to the DMV. License plates are issued in the pattern \(A_{1}A_{2}A_{2}A_{1}\) with the alphabets specified above. The order of significance is \(S_{4}S_{2}S_{1}S_{3}\). You're 2,673rd place in line for registering your vehicle, but you just can't wait. You need to know what your license plate is, right now! You might change your mind and want to swap places with someone else!
Let's go through the motions, starting with the most significant digit:
After plugging in the numbers, we get \(C_{3}=2\) (:
), \(C_{2}=1\) (4
), \(C_{4}=13\) (Y
), and \(C_{1}=3\) (1
). Putting that all together, we get the license plate 14:Y
. You then decide that this license plate is acceptable and wait patiently for 2,672 people in front of you to get their registrations complete. Unfortunately, when you are next in line, the DMV closes for the holidays.