uphill shooting problem 99

Back to General discussions forum

colin_mcnicholl     2019-05-28 09:08:52

I am afraid I do not properly understand the "the distance at which the bomb hits the slope, rounded down" part of the problem definition.

For:

input = '0 0 0 0 0 1 1 1 1 1 2 3 4 5 5 6 7 8 8 9 10 10 10 10 11 11 11 12 13 14 15 16 16 16 16 17 18 18 19 20\n38 56\n38 35\n32 64\n0 0 0 0 0 1 2 3 3 4 4 4 5 6 6 7 8 8 8 9 10 11 11 11 11 12 13 14 15 16 16 16 16 16 17 18 19 20 21 21\n31 66\n36 58\n36 48\n0 0 0 0 0 1 1 2 2 3 3 3 4 4 4 5 5 6 7 8 9 10 11 12 13 14 15 15 15 15 15 15 15 16 17 18 19 20 20 21\n35 62\n40 34\n34 63'

My output:

96 60 64 60 82 76 80 72 76

All correct except the 4th (1st result on 2nd profile) which is 1 more than expected result of 59.

I have: bomb height == 25.12, block height == 24, range == 59 bomb height == 23.69, block height == 28, range == 60 So this would be a case of the bomb hitting a vertical face.

There is a forum post dated 2016-01-18 in which Quandry gives a reply to Matthew Cole part of which is:

" If we try x=96, then y is 40.03, which is slightly higher than the cubes at that distance, which is 40.

If we try x=97, then y is 39.96, which is slightly lower than the cubes at that distance, which is 40.

As the answer has to be rounded down, 96 is the correct answer. "

Part of my confusion is x=96 or x=97 both integers so what is rounded?

Could someone help me out a little please ?

My output was correct for the example input data.

Rodion (admin)     2019-05-28 09:43:06
User avatar

Colin, Hi!

Thanks for reporting this...

I'm afraid I can't answer at once - I just have a peek at the checker and see that I wrote it so it models trajectory by simple integration with dt=0.003. I think this may give wrong (supposedly, rarely) incorrect results compared to precise parabola calculation.

Allow me please some time to check the input you kindly gave and find out whether it is such a case. If so, probably I should improve the checker, of course.

colin_mcnicholl     2019-05-29 12:58:22

OK Thanks for prompt interim response.

Not a problem I can wait.

In the meantime I maybe could make use of the information you supplied above.

Rodion (admin)     2019-06-01 06:25:49
User avatar

Dear Colin, hello again and sorry for it took bit long.

I first have checker rewritten and found the value for your case didn't match anyway...

So I read your explanations thoroughly, then tried to plot trajectory and finally I think I got it. As you may see in a picture below, your calculations of the height are correct.

  • the height of "step" between 56 and 60 is 24
  • the shell is above this at 59 but below at 60
  • vertical wall is at x=60, from y=24 to y=28

Thus the shell didn't hit vertical wall, but rather the last section of horizontal step short before the wall.

Trajectory plotted in Matlab 3.5

P.S. going to update checker with the "more exact" code now. Hope it won't break anything. :)

colin_mcnicholl     2019-06-01 10:48:37

Hi Rodion,

Thanks for taking the trouble to reply and give a good graphical explanation.

I think then I must add some additional calculations to my code.

Please login and solve 5 problems to be able to post at forum