24 lines
660 B
Python
24 lines
660 B
Python
import codewars_test as test
|
|
from solution import simplify
|
|
|
|
test.it("Test reduction by equivalence")
|
|
test.assert_equals(simplify("dc+dcba"), "cd+abcd")
|
|
|
|
test.assert_equals(simplify("2xy-yx"),"xy")
|
|
|
|
test.assert_equals(simplify("-a+5ab+3a-c-2a"),"-c+5ab")
|
|
|
|
test.it("Test monomial length ordering")
|
|
test.assert_equals(simplify("-abc+3a+2ac"),"3a+2ac-abc")
|
|
|
|
test.assert_equals(simplify("xyz-xz"),"-xz+xyz")
|
|
|
|
test.it("Test lexicographic ordering")
|
|
test.assert_equals(simplify("a+ca-ab"),"a-ab+ac")
|
|
|
|
test.assert_equals(simplify("xzy+zby"),"byz+xyz")
|
|
|
|
test.it("Test no leading +")
|
|
test.assert_equals(simplify("-y+x"),"x-y")
|
|
|
|
test.assert_equals(simplify("y-x"),"-x+y") |