I think you may need to modify some of the tests to "...ensure both odd and even values of x" in all cases where m might be negative.
Hi, Tim. Thanks for your feedback. Actually, from the Player's point of view, m 'could' be negative in any Test. I agree that in some situations there might not be one unique pair of the m & c parameter values that is correct. However, I never apply an assertion to the values of m & c in the Test Suite, rather I check what values of y the user-supplied parameters produce from the user-supplied function(handle). _Any_ valid combination of m & c should be able to REpredict the same values of y provided in the original input, from the same x values (or a subset thereof). There is only one test where I check for prediction of y using x values not included in the original input (extrapolation/interpolation), and for that one test I do have to be careful to ensure there is one unique pair of m & c values that is correct. So I would say this is intentional (I'll add a short note to the Problem Statement). But please let me know if there's a flaw in my logic. —DIV
Aha--I see now. To quote Emily Litella: "Never mind."
I should clarify one detail for other Players. Given y = mˣ + c (elementwise), suppose x is the vector [7 8 5 6] and y is the vector [123 123 123 123]. Then there are two valid combinations of m & c, namely m=0 & c=123 and m=1 & c=122. So actually there is not just one unique set of m & c values in this case. However, given x>0 (in the Problem Statement), either of these alternatives can be correctly extrapolated or interpolated from.
This solution fails sometimes, and I have no idea why (it's just a "smart" brute force code). I've tried to reproduce the error several times on my pc, but I wasn't able to. And I've even tried to use python's long to no avail . Probably I am underfitting at some cases, but it works sometimes. :)
There is definitely some issue.
From my perspective in writing the Test Suite a solution should either pass all of the Tests every time, or else fail at least one test every time.
I have therefore increased the number of testing iterations in selected Tests, and your solution consistently fails the revamped Tests 4, 5, and 6; it may also fail some other Tests that haven't been amended (e.g. Solution 3651713 failed test 7a).
I have also added quite a bit of detail in the rejigged failure messages so that you can identify problematic parameter values.
Remove the vowels
Inner product of two vectors
The Tower of Hanoi
Find the elements of a matrix according to a defined property.
Square Digits Number Chain Terminal Value (Inspired by Project Euler Problem 92)
Code breaker, Part I: Operation Phoenix
Testing for randomness: uniform distribution of real numbers (distribution checking)
"Percentages may not total 100 due to rounding"
Make your own Test Suite (part 1)
Comparison of floating-point numbers (singles)
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office