<reponame>matyama/codewars
import pytest

from codewars.binomial_expansion import expand


@pytest.mark.parametrize(
    "expr,expected",
    [
        ("(x+1)^0", "1"),
        ("(x+1)^1", "x+1"),
        ("(x+1)^2", "x^2+2x+1"),
        ("(x-1)^0", "1"),
        ("(x-1)^1", "x-1"),
        ("(x-1)^2", "x^2-2x+1"),
        ("(5m+3)^4", "625m^4+1500m^3+1350m^2+540m+81"),
        ("(2x-3)^3", "8x^3-36x^2+54x-27"),
        ("(7x-7)^0", "1"),
        ("(-5m+3)^4", "625m^4-1500m^3+1350m^2-540m+81"),
        ("(-2k-3)^3", "-8k^3-36k^2-54k-27"),
        ("(-7x-7)^0", "1"),
        ("(x+1)^2", "x^2+2x+1"),
        ("(p-1)^3", "p^3-3p^2+3p-1"),
        ("(2f+4)^6", "64f^6+768f^5+3840f^4+10240f^3+15360f^2+12288f+4096"),
        ("(-2a-4)^0", "1"),
        ("(-12t+43)^2", "144t^2-1032t+1849"),
        ("(r+0)^203", "r^203"),
        ("(-x-1)^2", "x^2+2x+1"),
        ("(3x-0)^2", "9x^2"),
        ("(0x-2)^3", "-8"),
        ("(0x+0)^2", "0"),
    ],
)
def test_expand(expr: str, expected: str) -> None:
    assert expand(expr) == expected

import pytest

from codewars.binomial_expansion import expand


@pytest.mark.parametrize(
    "expr,expected",
    [
        ("(x+1)^0", "1"),
        ("(x+1)^1", "x+1"),
        ("(x+1)^2", "x^2+2x+1"),
        ("(x-1)^0", "1"),
        ("(x-1)^1", "x-1"),
        ("(x-1)^2", "x^2-2x+1"),
        ("(5m+3)^4", "625m^4+1500m^3+1350m^2+540m+81"),
        ("(2x-3)^3", "8x^3-36x^2+54x-27"),
        ("(7x-7)^0", "1"),
        ("(-5m+3)^4", "625m^4-1500m^3+1350m^2-540m+81"),
        ("(-2k-3)^3", "-8k^3-36k^2-54k-27"),
        ("(-7x-7)^0", "1"),
        ("(x+1)^2", "x^2+2x+1"),
        ("(p-1)^3", "p^3-3p^2+3p-1"),
        ("(2f+4)^6", "64f^6+768f^5+3840f^4+10240f^3+15360f^2+12288f+4096"),
        ("(-2a-4)^0", "1"),
        ("(-12t+43)^2", "144t^2-1032t+1849"),
        ("(r+0)^203", "r^203"),
        ("(-x-1)^2", "x^2+2x+1"),
        ("(3x-0)^2", "9x^2"),
        ("(0x-2)^3", "-8"),
        ("(0x+0)^2", "0"),
    ],
)
def test_expand(expr: str, expected: str) -> None:
    assert expand(expr) == expected