Gets the max value supported by the given number system. >>> NumberingSystem.max_value("short") == 10**18 - 1 True >>> NumberingSystem.max_value("long") == 10**21 - 1 True >>> NumberingSystem.max_value("indian") == 10**19 - 1 True
(cls, system: str)
| 31 | |
| 32 | @classmethod |
| 33 | def max_value(cls, system: str) -> int: |
| 34 | """ |
| 35 | Gets the max value supported by the given number system. |
| 36 | |
| 37 | >>> NumberingSystem.max_value("short") == 10**18 - 1 |
| 38 | True |
| 39 | >>> NumberingSystem.max_value("long") == 10**21 - 1 |
| 40 | True |
| 41 | >>> NumberingSystem.max_value("indian") == 10**19 - 1 |
| 42 | True |
| 43 | """ |
| 44 | match system_enum := cls[system.upper()]: |
| 45 | case cls.SHORT: |
| 46 | max_exp = system_enum.value[0][0] + 3 |
| 47 | case cls.LONG: |
| 48 | max_exp = system_enum.value[0][0] + 6 |
| 49 | case cls.INDIAN: |
| 50 | max_exp = 19 |
| 51 | case _: |
| 52 | raise ValueError("Invalid numbering system") |
| 53 | return 10**max_exp - 1 |
| 54 | |
| 55 | |
| 56 | class NumberWords(Enum): |