Pure Programmer
Blue Matrix


Cluster Map

Project: License Plate Generator (Revisited)

Assume that you supply software for the Department of Motor Vehicles in all 50 states. Write a program that generates all the possible license plate numbers and then prints the total number of plates at the very end. Your program should accept one command line argument that provides the pattern to use when generating licenses. Any of the characters 'A'-'Z' represents the alpha characters in the plate number whereas any of the characters '0'-'9' represents digits. Any other character just represents itself.

Your program should contain a function that accepts one character from the pattern and returns an array containing all the possible characters that character could represent. For the alphabetic pattern don't allow 'I', 'O' and 'S' letters because they can be confused with digits.

Start with license plate numbers that use the pattern ABC-123. Run the program with the pattern that your state uses. See [[License Plate Designs]]. Make sure your program works with the following patterns:

American Samoa1234
Arkansas123 ABC
California1ABC234
Delaware123456
MissouriAB1 C2D
Nevada12A-345
Rhode Island123-456
TennesseeA12-34B

Output
$ perl LicensePlates2.pl AA1-A1A AA0-A0A AA0-A0B AA0-A0C AA0-A0D AA0-A0E AA0-A0F AA0-A0G AA0-A0H AA0-A0J AA0-A0K ... ZZ9-Z9Q ZZ9-Z9R ZZ9-Z9T ZZ9-Z9U ZZ9-Z9V ZZ9-Z9W ZZ9-Z9X ZZ9-Z9Y ZZ9-Z9Z Total: 27984100 $ perl LicensePlates2.pl 1ABC234 0AAA000 0AAA001 0AAA002 0AAA003 0AAA004 0AAA005 0AAA006 0AAA007 0AAA008 0AAA009 ... 9ZZZ991 9ZZZ992 9ZZZ993 9ZZZ994 9ZZZ995 9ZZZ996 9ZZZ997 9ZZZ998 9ZZZ999 Total: 121670000 $ perl LicensePlates2.pl ABC-123 AAA-000 AAA-001 AAA-002 AAA-003 AAA-004 AAA-005 AAA-006 AAA-007 AAA-008 AAA-009 ... ZZZ-991 ZZZ-992 ZZZ-993 ZZZ-994 ZZZ-995 ZZZ-996 ZZZ-997 ZZZ-998 ZZZ-999 Total: 12167000 $ perl LicensePlates2.pl 1234 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 ... 9991 9992 9993 9994 9995 9996 9997 9998 9999 Total: 10000

Solution