Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
f.removesuffix.removeprefix solution in Clear category for Write Quadratic Equation by veky
def write(k, x):
if not k: return ''
space = '' if '2' in x else ' '
return space.join(['', '-' if k < 0 else '+' if space else '',
f"{abs(k)}*{x}".removesuffix('*').removeprefix('1*')])
def quadr_equation(data: list[int]) -> str:
match data:
case a, x0 : return quadr_equation([a, x0, x0])
case a, x1, x2: return write(a, 'x**2') + write(-(x1 + x2) * a, 'x') \
+ write(x1 * x2 * a, '') + ' = 0'
Aug. 22, 2022