forked from CodeMouse92/DeadSimplePython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlicense_plates.py
More file actions
44 lines (34 loc) · 934 Bytes
/
license_plates.py
File metadata and controls
44 lines (34 loc) · 934 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
39
40
41
42
43
44
from itertools import product
from string import ascii_uppercase as alphabet
# def license_plates():
# for num in range(1000):
# yield f"ABC {num:03}"
# license_plates = (
# f"ABC {number:03}"
# for number in range(1000)
# )
license_plates = (
f'{letters} {number:03}'
for letters in (
"".join(chars)
for chars in product(alphabet, repeat=3)
)
if letters != 'GOV'
for number in range(1000)
)
# for plate in 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 True
return False
# 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(registrations[name])