6 kyu

Projectile Motion

132 of 358narayanswa30663
Description
Loading description...
Fundamentals
View
AllIssues11Questions3Suggestions3Show Resolved
  • Please sign in or sign up to leave a comment.
  • saudiGuy Avatar

    looks like image is broken.. ?

  • KuuuGR Avatar

    This comment has been deleted.

  • KuuuGR Avatar

    XCTAssertEqual failed: ("h(t) = -16.0t^2 + 17.880t + 51.0") is not equal to ("h(t) = -16.0t^2 + 17.88t + 51.0") - XCTAssertEqual failed: ("x(t) = 83.070t") is not equal to ("x(t) = 83.07t") -

    R E A L L Y ???

  • Egor318 Avatar

    Отличное ката. При внимательном прочтении условия, все становится ясным и понятным. Автору огромное спасибо!

  • RustamNigmatullin Avatar

    very inaccurate description and template

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • Almale02 Avatar

    use meters please

  • zdreagin Avatar

    There are some TypeScript test cases which are incorrect. The description very explicitly states that integer output should have a decimal point with a zero afterwards, and that all other numbers should be rounded to 3 decimal places. In some test cases, however, numbers are rounded to only 2 decimal places. It seems to be the case that when the final digit is a zero, it is omitted in the test cases. This appears to be the same issue that other users have been facing in other languages.

    Examples: expected 'h(t) = -16.0t^2 + 17.880t + 51.0' to equal 'h(t) = -16.0t^2 + 17.88t + 51.0' expected 'x(t) = 33.340t' to equal 'x(t) = 33.34t'

  • RJPlog Avatar

    This comment has been hidden.

  • KonstIs Avatar

    Hi, I have the same problem, can't pass tests in swift: main.swift:86:18: error: type of expression is ambiguous without more context let p1 = Projectile(h: a, v0: b, a: c); Please give me a hint as to where the error might be.

  • RustamNigmatullin Avatar

    can't pass tests (swift):

    main.swift:86:18: error: type of expression is ambiguous without more context let p1 = Projectile(h: a, v0: b, a: c); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ wrong test? why h is a and a is c?

  • JiPiBi Avatar

    Hi , just a remark : as int values are expected to be printed as .0 , perhaps could you have asked for same format for y value in landing return

  • PLIVAN Avatar

    I'm getting lost though is the example of p = new Projectile(5, 2, 45). When I put that into my Groovy code where a = -16, b = 2, c = 45 I get q = -0.5 and q = 0.625 and the example results for this should be q = 0.605.

    I don't understand where this 0.02 difference is coming from. Is there an error in my quadratic function code I'm not seeing or is this maybe something Groovy related versus how the example results were generated?

  • Crasty Avatar

    feets DansGame

  • imjasonmiller Avatar
  • netizenx Avatar

    I wasted a lot of time trying to figure out why I was just a bit off. The tests use gravity as 32 ft / s exactly instead of 32.2 or 32.174. Only after figuring out the problem did I notice the -16t^2 term denoted 1/2(g)(t^2), thus showing the assumption.

  • Chrono79 Avatar

    The tests in javascript (see Dart issue raised below) expect some numbers with two or zero decimals in random tests, in the instructions it says otherwise:

    EVERYTHING, including values in the equations appearing as coefficients, must be rounded to THREE decimal places. However, if the value is whole, only show one decimal place

  • Spaceman-C-- Avatar

    I'm doing this exercise in Groovy and trying to solve the total time the projectile is in the air, so when h = 0.

    I've implemented the quadratic equation shown here: https://www.khanacademy.org/math/algebra/quadratics/solving-quadratics-using-the-quadratic-formula/a/quadratic-formula-review into Groovy like so: def q = (-b + Math.sqrt((Math.pow(b,2) - (4*a*c))))/(2*a)

    Using the example from Khanacademy, a = −7, b = 2, c = 9 in my Groovy code I get the expected results of q = -1 and q = 1.2857142857142858 (9/7).

    Where I'm getting lost though is the example of p = new Projectile(5, 2, 45). When I put that into my Groovy code where a = -16, b = 2, c = 45 I get q = -0.5 and q = 0.625 and the example results for this should be q = 0.605.

    I don't understand where this 0.02 difference is coming from. Is there an error in my quadratic function code I'm not seeing or is this maybe something Groovy related versus how the example results were generated?

  • JohnaBell Avatar

    Below is the error code for Dart test Projectile(51, 86, 12)

    Expected: 'h(t) = -16.0t^2 + 17.88t + 51.0' Actual: 'h(t) = -16.0t^2 + 17.880t + 51.0' Which: is different. Expected: ... ^2 + 17.88t + 51.0 Actual: ... ^2 + 17.880t + 51.0 ^ Differ at offset 23

    The description says that everything should be given to three decimal places except for integer values that should be give to one decimal place.

  • gbhojraj Avatar

    Javascipt (and maybe Dart)- It seems that either the tests are wrong or the example needs to be updated- should trailing 0s be included in formulas? One of the test cases I failed in Javascript:

    Expected: 'x(t) = 83.07t', instead got: 'x(t) = 83.070t' Expected: 'h(t) = -16.0t^2 + 13.2t + 86.0', instead got: 'h(t) = -16.0t^2 + 13.200t + 86.0'

    The instructions say: EVERYTHING, including values in the equations appearing as coefficients, must be rounded to THREE decimal places. However, if the value is whole, only show one decimal place (for example => -16 becomes -16.0, not -16.000)

  • andysco Avatar

    This is brilliant. A massive thankyou to the author(narayanswa30663 is it?). This is my first ever attempt at writing a class and I am delighted that this kata gives me a very gentle introduction into how to include variable and methods. This is exactly the sort of thing I was looking for. I love codewars. I am learning sooo much.

  • chrislucas Avatar

    The example of how to implement the "height(t)" method is wrong

    "p.height(0.2) #=> 4.643 (Calculation: -16(0.2)^2 + (2cos(45º))(0.2) + 5)"

    Should be (2sin(45º))(0.2), like describe in height_eq method. we should use sin function, I guess

  • NCarter Avatar

    How are you supposed to calculate the x and t value for the final function?

  • NCarter Avatar

    In the kata description, in the example it says "1.414 = 2sin(45º)" but 2sin(45) is 1.702 so my answer for height_eq will always be wrong

  • jaro_kalisz Avatar

    Thers is still problem with expected formatting and its description.

    "EVERYTHING, including values in the equations appearing as coefficients, must be rounded to THREE decimal places. However, if the value is whole, only show one decimal place (for example => -16 becomes -16.0, not -16.000)" implicates that there should be 3 or 1 decimal place, but I've got error:

    Expected string length 31 but was 32. Strings differ at index 23. Expected: "h(t) = -16.0t^2 + 23.84t + 64.0" But was: "h(t) = -16.0t^2 + 23.840t + 64.0" ----------------------------------^

    EDIT: My next attempt, with 1, 2 or 3 decimal places:

    Expected string length 28 but was 30. Strings differ at index 19. Expected: "h(t) = -16.0t^2 + 0t + 161.0" But was: "h(t) = -16.0t^2 + 0.0t + 161.0" ------------------------------^

    So it excpected no decimal places now.

  • fefe982 Avatar

    (Scala) Some random test give me a feedback say that the expected result for heightEq() would be -16.0t^2 + 0.000t + ????.

    While the description explicitly says: "NOTE: Some solutions were invalidated because I added tests for situations where the starting height is 0, in which case the equation for height would be in the form h(t) = -16.0t^2 + vt where v represents the initial vertical velocity.", shouldn't the 0 second term be omitted?

    Also, why the second term has three decimal points?

  • xDJxYummY Avatar

    I really enjoyed this Kata, it made me remember some formulas I haven't used in a long time!!

  • siebenschlaefer Avatar

    EVERYTHING, including values in the equations appearing as coefficients, must be rounded to THREE decimal places.

    But the tests want heightEq to format h0 with ONE decimal place. Also: The TypeScript version has no sample tests.

  • Blind4Basics Avatar
    • formatting problems in the description (java code block at least, seems to miss some line feeds)
    • Java: you have to tell in the description the type of the arguments for the constructor and the different methods (some can be approximately deduced from the description, but that's not a good idea to let the user in the dark with a strongly typed language. So that applies to other typed languages).
  • Blind4Basics Avatar

    Errrr.... WTH!?

    h = -16t²+... => how did you end up with 16!?? That should be g/2 = 9.81/2 = 4.405

    ... Unless you're not on Earth but you do not tell about it... xp

  • Chrono79 Avatar

    Why a formula with b and another with v? Aren't those 2 the same?

    b represents the initial vertical velocity

    v represents the initial vertical velocity

  • narayanswa30663 Avatar

    NOTE: Some solutions were invalidated because I added tests for situations where the starting height is 0, in which case the equation for height would be in the form h(t) = -16t^2 + bt where b represents the initial vertical velocity. Sorry!

  • Voile Avatar

    Why t has to be rounded to 3 decimal places before calculating the x position when hitting the ground? Especially when description says this:

    But ensure that you DO NOT use the three-decimal-place rounded values for calculations.