-
1 Comment
OK, how did I get it this small? A few hints.
There are no loops and no colon operators in my solution; I did some clever integrals up front to avoid them. I do call str2num twice (with fewer than 5 numbers in each call), and I leverage the savings of assigning to the variable ans.
Otherwise, I use the normal operators (+ - * / ^) and some pretty common MATLAB functions; polyval() being the most exotic.
There are also two "fudge factors". One I calculated on my own PC, the second was tailored to match Ramon's answers for a few marginal cases where the sum was very nearly a half integer. Both of those fudge factors conveniently fit within the str2num() calls.
Suggested Problems
-
25984 Solvers
-
Determine whether a vector is monotonically increasing
21338 Solvers
-
Find all elements less than 0 or greater than 10 and replace them with NaN
15612 Solvers
-
Easy Sequences 36: Hyperbolic Lattice Points
7 Solvers
-
Count the unitary divisors of a number
11 Solvers
More from this Author116
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!