-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIMOGenerator.py
More file actions
54 lines (50 loc) · 1.35 KB
/
IMOGenerator.py
File metadata and controls
54 lines (50 loc) · 1.35 KB
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
45
46
47
48
49
50
51
52
53
54
# SPDX-FileCopyrightText: Balraj Singh Bains and Magenta ApS <info@magenta.dk>
#
# SPDX-License-Identifier: MPL-2.0
# Original by Balraj Singh Bains here:
# https://gist.github.com/polltery/e664f4846fe473a7d6231a5bdd6509e5
# Transpiled to python by Magenta ApS in 2025
def is_imo_valid(imo):
if imo is None or len(imo) != 7:
return False
a = list(imo)
sum_ = 0
for i in range(6):
sum_ += (int(a[i])) * (len(a) - i)
return sum_ % 10 == int(a[6])
def main():
a = 0 # 1
b = 0
c = 0 # 3
d = 0
e = 0 # 5
f = 0
g = 0 # 7
imo = ""
while imo.lower() != "9999999":
imo = f"{a}{b}{c}{d}{e}{f}{g}"
if is_imo_valid(imo):
print(imo)
g += 1
if g == 9:
g = 0
f += 1
if f == 9:
f = 0
e += 1
if e == 9:
e = 0
d += 1
if d == 9:
d = 0
c += 1
if c == 9:
c = 0
b += 1
if b == 9:
b = 0
a += 1
if a == 9:
break
if __name__ == "__main__":
main()