[Community Puzzle] WW2 Mortar Warfare

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @zakacat,validated by @FredericLocquet,@cedricdd and @chris.steele.
If you have any issues, feel free to ping them.

Is there an error with test case 3? The angles I get are 23.3 deg and 66.7 degrees. 66.7 is within the mortar’s elevation limits and yields a range of 1850. By my calculations, the mortar’s maximum range should be 2547 m, well over 1850. What am I missing?

The maximum range of the mortar is always 1800 m because of the description.

Oh, thanks. I must have scanned past that without reading it a dozen times.

1 Like

Thank you for this original contribution !

The code I wrote passes all validators and all tests but one : test #2 “more precision”.
For this test, my code computes a flight time t = 31,825135057840544 s. I find the same value when doing the calculation by hand with a desktop calculator, applying the given formulas.

Rounding this to the nearest tenth of a second yields 31.8 s . The test expects 31.9 s .
Is my computed flight time incorrect ? Or am I misunderstanding “round to the nearest tenth of a second” ?

What value of theta did you use to get t = 31.825135057840544?

The value of theta is 1.4156514941328739 radians (after symmetry around pi/4)
which is 81.110855875202702 degrees
which rounds to 81.1 degrees which is the test expected value.

My code produces these values, which are different from yours:
theta = 81.12021915403635 degrees
t = 31.858423514251033 seconds => 31.9 seconds

I think I may know how you got 81.110855875202702: you used 9.81 instead of 9.8 as provided in the statement.

1 Like

ah ha you’re right ! I have just come to the same conclusion : I used a different value for the constant g than the statement gives. Thanks for your help sorting this out !

There is nothing special about this puzzle

Thanks for sharing this insight, dude :wink:

I have a problem calculating the required values. Is there anything else I have to do mathematically wise, except using the provided formulas? The first test case calculates to 55.9 degrees for theta. I also did the calculation in other math tools and got the same result.

Any hints?


You shouldn’t have to do anything else than using the formula, for the first test case you should find that theta is 0.0987 in radiant => 5.6598° or 84.3402° (90 - 5.6598)

Hello, I don’t know why but with my solution, all tests are validated and when submitting, the “easy calculation” validator fails. Could you explain to me why ?


You could test if your code works with the custom test:

82.9 degrees
32.0 seconds

Thank you, I found my mistake, my code wasn’t print the result with ,0

Hello, my code give, for a range of 500 metres, theta=5.659831002288709°.

90°-5.659831002288709° …

I don’t know much about physics so at first the formula’s looked to cryptic to me but I was finally able to solve the puzzle with some help from ChatGPT :slight_smile: