Problem 964. McCabe Complexity
The Challenge is to return the McCabe complexity for various functions.
One way to determine the McCabe Complexity is to use the form:
checkcode -cyc polyval.m
which returns: L 1 (C 23-29): The McCabe complexity of 'polyval' is 19.
Input: Function name (string)
Output: McCabe Complexity (numeric)
Example:
For 'polyval.m' the expected output is 19.
For some functions there are structures and fields which complicates finding the McCabe complexity value.
The McCabe complexity is used in the scoring of the Matlab Semi-annual contests. Complexities higher than 10 induce severe penalties.
Solution Stats
Problem Comments
-
3 Comments
Chris Cleveland
on 19 Jul 2017
Excellent problem!!! Cody is a great for getting acquainted with Matlab features I have never used.
Rafael S.T. Vieira
on 31 Oct 2020
It seems that the first case of the test suite is still being called which generates an error and makes impossible to solve the problem without hacks. The polyval function's complexity currently is 22, not 19. Please remove the test case (which will not render previous solutions false) or update its value.
goc3
on 3 Nov 2020
The troublesome first line in the test suite has been commented out and old solutions re-scored.
Solution Comments
Show commentsProblem Recent Solvers39
Suggested Problems
-
2327 Solvers
-
How to find the position of an element in a vector without using the find function
2737 Solvers
-
1642 Solvers
-
470 Solvers
-
290 Solvers
More from this Author308
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!