After pulling my hair out, I have a couple of suggestions. The problem is to find the 'best estimate,' which I and many others attempting this problem took to be the mean expected value, the solution sought after historically. It's actually asking for the most likely single value. I suggest editing the problem description to make that clear.
I now see that the most likely value will always be m. In the process, I discovered that some of the test cases violate the assumptions of the problem, cases where the maximum value observed is less than the number of samples. I would correct this for the sake of those who don't immediately realize that the most likely single value will always be the maximum value observed.
The lack of clarity and problems with the test cases caused me to waste a good deal of time.
Thanks for the suggestions. I really did not want the problem to expelout the solution that it is "asking for", but let players figure that out from the description given in "To pass this problem you must be exactly correct in at least 10% of the testsuite cases". I understand this can feel misleading, but the point was to make this problem more like a "escape room" puzzle than an straight up homework problem. And regarding the "incorrect" test cases, the tests are probabilistic, so of course in some of them your "optimal" solution will not get the number of samples right, but that is perfectly fine, 10% success rate is all that is expected/required to pass this problem
Test  Status  Code Input and Output 

1  Pass 
Ntest=1e4;
N=randi([10,100],Ntest,1);
K=randi([1 10],Ntest,1);
M=arrayfun(@(N,K)max(randi(N,1,K)),N,K);
N_hat=arrayfun(@tank_problem,K,M);
rate=mean(N==N_hat);
assert(rate>=.1,sprintf('hit rate too low (%0.2f%%)',rate*100));
fprintf('hit rate = %0.2f%%\n',rate*100);
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits]
[> In nchoosek (line 92)
In tank_problem (line 20)
In ScoringEngineTestPoint1 (line 5)
In solutionTest (line 3)]
[Warning: Result may not be exact. Coefficient is greater than 9.00...

6474 Solvers
Find the alphabetic word product
2258 Solvers
Without the French accent please!
99 Solvers
Piecewise linear interpolation
256 Solvers
Polite numbers. Nth polite number.
122 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!