REPOSITORY CODING · MEDIUM
Exact long division divides leading coefficients and cancels shifted divisor terms until the remainder degree is smaller
Exact long division divides leading coefficients and cancels shifted divisor terms until the remainder degree is smaller. The complete application includes native models, services, repository projections, a working preview and visible acceptance cases. Preserve the other documented invariants and run bash test/run.sh.
symbolic-algebraExact polynomial arithmetic laboratory
Work through a real codebase.
Choose an environment, investigate the existing implementation and use the tests to check your change. Sign in to open a workspace; execution and Ono usage follow your plan’s allowances.
Task requirements and environments
C++ · 55 minute session
- Normalize rational coefficients to reduced numerator/positive-denominator pairs. Zero always has denominator one.
- Polynomial multiplication convolves every coefficient pair and adds all contributions at the same degree.
- Exact long division divides leading coefficients and cancels shifted divisor terms until the remainder degree is smaller.
- Return the monic polynomial greatest common divisor and compute the formal derivative with its degree multiplier.
- Sturm variations ignore zero evaluations and negate every Euclidean remainder. Count distinct real roots in the half-open interval (left,right].
- Ascending integer input coefficients between minus twenty and twenty, degree at most six. Rational outputs are exact and intermediate magnitudes are bounded. The zero polynomial has indeterminate root count; division by zero is rejected.