There are N=2^n bags of rice looking alike, N-1 of which have equal weight and one is slightly heavier. The weighing balance is of unlimited capacity. Using the balance, the minimum number of weighing required to identify the heavier bag is?
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.
Correct the test suite
Increment a number, given its digits
Project Euler: Problem 1, Multiples of 3 and 5
Test if two numbers have the same digits
find radius of cone
Side of a rhombus
RMS value from a set of observations
Generate pi using logarithm
Find the solution of algebraic equation
Accessing elements on the diagonal
Find out missing number from a vector of 9 elements
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