Skip to content
Snippets Groups Projects

Publikace výsledkovky na web MO

1 file
+ 9
9
Compare changes
  • Side-by-side
  • Inline
+ 9
9
@@ -2,21 +2,21 @@
from datetime import datetime
import decimal
from typing import Optional
from typing import Optional, Union
import mo
def inflect_number(n: int, w1: str, w234: str, wother: str, unitprefix: str = '') -> str:
if n == 1:
return f'{n} {unitprefix}{w1}'
elif 2 <= n <= 4:
return f'{n} {unitprefix}{w234}'
else:
return f'{n} {unitprefix}{wother}'
def inflect_number(n: Union[int, decimal.Decimal], w1: str, w234: str, wother: str, unitprefix: str = '', wdecimal: Optional[str] = None) -> str:
return f"{format_decimal(n) if type(n) == decimal.Decimal else n} {inflect_by_number(n, w1, w234, wother, unitprefix=unitprefix, wdecimal=wdecimal)}"
def inflect_by_number(n: int, w1: str, w234: str, wother: str, unitprefix: str = '') -> str:
def inflect_by_number(n: Union[int, decimal.Decimal], w1: str, w234: str, wother: str, unitprefix: str = '', wdecimal: Optional[str] = None) -> str:
""" Vybere správnou koncovku podle čísla.
Číslo může být int nebo desetinné číslo reprezentovavné pomocí Decimal.
"""
if n % 1 != 0:
return f'{unitprefix}{wdecimal or wother}'
if n == 1:
return f'{unitprefix}{w1}'
elif 2 <= n <= 4:
Loading