Given two vectors p1 and p2, return the slope of a line that passes through p1 and p2.
Examples:
Input [p1,p2] = deal([0,1],[1,3])
Output m = 2
Input [p1,p2] = deal([-2,0],[0,1])
Output m = 0.5
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers53
Suggested Problems
-
Select every other element of a vector
36155 Solvers
-
Swap the first and last columns
22529 Solvers
-
467 Solvers
-
Sum the 'edge' values of a matrix
400 Solvers
-
Find the Oldest Person in a Room
20261 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
P.S. This is supposed to be a beginner problem; there is no actual difficulty or challenge ?
Thanks for contributing a problem, Ashley. I think it's good to have problems that cover a range of difficulty so that players of all levels can engage with Cody. Your problem's description is clear and concise, and it has a decent number of tests: others recommend at least four tests to discourage lookup solutions.
One suggestion is to use the search tool to check whether others have written similar problems. In this case Cody Problem 43546 is similar. I wrote two problems that I later learned repeat existing problems. Now I check and change the idea if I find a similar existing problem.