4 kyu

Differentiate a polynomial

822 of 3,008samhstn

Description:

Create a function that differentiates a polynomial for a given value of x.

Your function will receive 2 arguments: a polynomial as a string, and a point to evaluate the equation as an integer.

Assumptions:

  • There will be a coefficient near each x, unless the coefficient equals 1 or -1.
  • There will be an exponent near each x, unless the exponent equals 0 or 1.
  • All exponents will be greater or equal to zero

Examples:

differenatiate("12x+2", 3)      ==>   returns 12
differenatiate("x^2+3x+2", 3)   ==>   returns 9
differenatiate("12x+2", 3)      ==>   returns 12
differenatiate("x^2+3x+2", 3)   ==>   returns 9
differenatiate("12x+2", 3)      ==>   returns 12
differenatiate("x^2+3x+2", 3)   ==>   returns 9
Equation.differenatiate("12x+2", 3)      ==>   12
Equation.differenatiate("x^2+3x+2", 3)   ==>   9
Algorithms
Strings
Fundamentals

Similar Kata:

More By Author:

Check out these other kata created by samhstn

Stats:

CreatedDec 7, 2015
PublishedDec 7, 2015
Warriors Trained13591
Total Skips5262
Total Code Submissions31766
Total Times Completed3008
JavaScript Completions822
Python Completions1779
Ruby Completions107
Java Completions333
Total Stars438
% of votes with a positive feedback rating95% of 530
Total "Very Satisfied" Votes482
Total "Somewhat Satisfied" Votes43
Total "Not Satisfied" Votes5
Total Rank Assessments4
Average Assessed Rank
4 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
5 kyu
Ad
Contributors
  • samhstn Avatar
  • Unnamed Avatar
  • smile67 Avatar
  • Blind4Basics Avatar
  • FArekkusu Avatar
  • hobovsky Avatar
Ad