forked from CodeMouse92/DeadSimplePython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlicense_generator.py
More file actions
38 lines (26 loc) · 825 Bytes
/
license_generator.py
File metadata and controls
38 lines (26 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from itertools import product
from string import ascii_uppercase as alphabet
def gen_license_plates():
for letters in product(alphabet, repeat=3):
letters = "".join(letters)
if letters == 'GOV':
continue
for numbers in range(1000):
yield f'{letters} {numbers:03}'
license_plates = gen_license_plates()
# for plate in license_plates:
# print(plate)
registrations = {}
def new_registration(owner):
if owner not in registrations:
plate = next(license_plates)
registrations[owner] = plate
return plate
return None
# Fast-forward through several results for testing purposes.
for _ in range(4441888):
next(license_plates)
name = "Jason C. McDonald"
my_plate = new_registration(name)
print(my_plate)
print(registrations[name])