I think it only takes 5 weighings when N=128. Am I incorrect?
agree 5 weighing for N=128 (worst case scenario you reduce to 43 15 5 2 1 after each consecutive weighing)
the last test case provided by the author is wrong: should be 5 since log(128)/log(3) < 5.
The problem is that the author do not specify an strategy. And as mentioned, dividing by 3 yields a better strategy than 6 weightings for 128. But, my guess is that the author counted the number of divisions instead of the number of weightings 128->[42 42 43] -> [14 14 14; 14 14 15]->[5 5 4; 5 5 5]->[2 2 0; 2 2 1]->[1;2]->1.
Correct the test suite
Angle of triangle
Size of this cup?
Back to basics 15 - Benchmark
Back to basics 7 - Equal NaNs
Matrix which contains the values of an other matrix A at the given locations.
Find out missing number from a vector of 9 elements
Generate pi using logarithm
Find the solution of algebraic equation
Reverse the elements of an array
Accessing elements on the diagonal
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