-
Notifications
You must be signed in to change notification settings - Fork 0
/
dec2cyrs_demo.py
59 lines (52 loc) · 2.46 KB
/
dec2cyrs_demo.py
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
55
56
57
58
59
def dec2cyrs(input_number, use_titlo=False):
if not 1 <= input_number <= 9999999999:
raise ValueError("The number must be from 1 to 9999999999")
cyrillic_symbols = {
1000000000: ["а꙲", "в꙲", "г꙲", "д꙲", "є꙲", "ѕ꙲", "з꙲", "и꙲", "ѳ꙲"], 100000000: ["а꙱", "в꙱", "г꙱", "д꙱", "є꙱", "ѕ꙱", "з꙱", "и꙱", "ѳ꙱"],
10000000: ["а꙰", "в꙰", "г꙰", "д꙰", "є꙰", "ѕ꙰", "з꙰", "и꙰", "ѳ꙰"],
1000000: ["а҉", "в҉", "г҉", "д҉", "є҉", "ѕ҉", "з҉", "и҉", "ѳ҉"],
100000: ["а҈", "в҈", "г҈", "д҈", "є҈", "ѕ҈", "з҈", "и҈", "ѳ҈"],
10000: ["а⃝", "в⃝", "г⃝", "д⃝", "є⃝", "ѕ⃝", "з⃝", "и⃝", "ѳ⃝"],
1000: ["҂а", "҂в", "҂г", "҂д", "҂є", "҂ѕ", "҂з", "҂и", "҂ѳ"],
100: "рстуфхѱѡц",
10: "іклмнѯѻпч",
1: "авгдєѕзиѳ"
}
result = ""
for divisor, symbols in cyrillic_symbols.items():
quotient, input_number = divmod(input_number, divisor)
if quotient > 0:
if isinstance(symbols, list):
if quotient <= len(symbols):
result += symbols[quotient - 1]
else:
result += symbols[-1] * quotient
elif divisor == 10 and 1 <= quotient <= 9:
tens = symbols[quotient - 1]
ones = cyrillic_symbols[1][input_number - 1] if input_number > 0 else ""
if 11 <= (quotient * 10 + input_number) <= 19:
result += ones + tens
else:
result += tens + ones
break
else:
result += symbols[quotient - 1]
if use_titlo:
titlo = "҃"
if len(result) == 1:
result = result + titlo
else:
result = result[:-1] + titlo + result[-1]
return result
use_titlo = True
#use_titlo = False
for i in range(1, 9999999999):
print(f"{i}; {dec2cyrs(i, use_titlo=use_titlo)}")
print(f"1; {dec2cyrs(1, use_titlo=use_titlo)}")
print(f"11; {dec2cyrs(11, use_titlo=use_titlo)}")
print(f"111; {dec2cyrs(111, use_titlo=use_titlo)}")
print(f"1111; {dec2cyrs(1111, use_titlo=use_titlo)}")
print(f"1; {dec2cyrs(1, use_titlo=False)}")
print(f"11; {dec2cyrs(11, use_titlo=False)}")
print(f"111; {dec2cyrs(111, use_titlo=False)}")
print(f"1111; {dec2cyrs(1111, use_titlo=False)}")