My results are all different, although the formula gets the right result in all the simple cases like hs=H/2; ha=H/2; xs=0; xa=0; etc...
I’m checking my solution…
I updated the test suites. I made a mistake in using full diameter instead of the semicircle's diameter. I also added a clarification to ensure only one option is considered.,
With regards to your solution. I think that your algorithm will work only if both the ant and spider are in the same side. Please take note that the ant is inside and the spider is outside. Please try again. Thanks.
The dotted line doesn't show it, but presumably the spider has to go up, over the top edge of the can, and down again. Also it can presumably choose whether to go clockwise or counterclockwise.
Hi William, I've included one solution into the problem itself. I hope this clarifies everything. Of course the circumference will not change. But if you would not consider inside/outside, the insects will appear to be closer together, and you will be get shorter distance than the correct one.
Try to imagine that the can is a sngle piece of paper folded in half and after which the edges perpendicular to the fold are joined together to form a cylinder.
Yes, that is exactly how I was imagining it, and I think my solution correctly computes the result for that situation. But unfortunately it only agrees with your numbers in the case of problem 1 (for which hs=ha and xs=xa).
William, you've corrected your net height after considering the spider/ant are outside/inside. That means viewing it flat, you have now one correct triangle side. You also need to adjust the other triangle side, again considering inside/outside.
Sorry, but I think it is incorrect to change the other side. The circumferential distance does not change as a result of inside/outside.
That solution has an error. In the equations for wa and ws, you should not be dividing by 2*pi.
Your right. Thanks so much...
I think that your algorithm will work only if both the ant and spider are in the same side. Please take note that the ant is inside and the spider is outside. For example, your formula for the net height is H - hs - ha. This is correct if they are on the same side. The correct net height should be: H - hs + ha. Thanks.
Alphabetize by last name
Create a square matrix of multiples
Create One Large Eye of size N x N Quickly?
Unique values without using UNIQUE function
Return fibonacci sequence do not use loop and condition
Easy Sequences 29: Odd proper divisors of odd proper divisors
Easy Sequences 26: Prime-Integer Line Segments
Easy Sequences 49: Prime Little Omega Function
Easy Sequences 13: Average Speed of Spaceship
Easy Sequences 48: Prime Big Omega of Factorial Sequence
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