Problem 44387. Birthday cake
Solution Stats
Problem Comments

16 Comments
The Test Suite has the highest minDist as 16 for a cake of size 16×32, but I am getting 16.564. Likewise for a couple of other sizes.
Thanks for the feedback, David. You are absolutely correct. I will fix the test suite.
Ok, I have updated the result for tests 3 and 7. Also, I changed the requirement from 3 decimal places to 2 so that minor discrepancies aren't as big an issue. Please let me know if you catch any other errors.
Thanks. I think it's all good now :)
well, this was harder than I was anticipating :)
It might be advisable to include additional test cases to avoid hardcoded & nongeneral 'solutions'. Some additional cases are reported in Solution 1299656.
I second David's suggestion
I agree, David. I'll expand the test suite today.
great! one suggestion would be to add some cases with cake sides ratios between .45 and .55 but different than .5 to avoid solutions that hardcode the .5 case? (e.g. birthdaycandles(5,11) = 5.5204 ; birthdaycandles(12,23) = 12.2028). The behavior in that range seems most interesting, as the solution space seems to transition smoothly between the two "stable" configurations
Done. Thanks for helping me refine things further, Alfonso.
The last two cases have a solution of 258.83 and 517.65, I am getting 258.82 and 517.64 respectively. Is this intended and I am wrong? or is it just numerical roundoff?
I agree with Daniel Turizo that the roundoff is wrong for the two last cases. I had to introduce a fudge factor of 1.00003 to get the value in the test suite, even though I use an analytical solution.
That right. I am also using an analytical solution and I had to introduce that ugly 1.0003 factor too.
Daniel and Are, thanks for the input. I modified the requirements so that the player should not need to round to 2 decimal places anymore. The "correct" answers now have higher precision, and a solution's answer must be within a tolerance of 0.01. With this format, you should not need the fudge factor you were using (either way, at least one of your submissions should work!).
I am getting 517.6381 for test #23 (same value using algebraic formula or 1d optimization) compared to the testsuite 517.6500 value, could you please doublecheck?
Good catch. Test suite updated.
Solution Comments

1 Comment
New tests will be added to make this hardcoded solution obsolete.

1 Comment
почему b = 2 * wid  sqrt(3) * len / 2;?

2 Comments
Not a general solution.
yeah! I've done the same... ))

3 Comments
Not a general solution.
Seems like a general approach to me, but the boundaries are not correct. I found it easier to calculate the three options, and then pick the worst.
Fair point.

1 Comment
Good insight in your formula for the first case of your if statement.
Problem Recent Solvers85
Suggested Problems

3793 Solvers

1224 Solvers

Create logical matrix with a specific row and column sums
223 Solvers

Relative ratio of "1" in binary number
824 Solvers

Find the next Fibonacci number
391 Solvers
More from this Author44
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!