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

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?

Iterating one time is orthogonal to using exceptions for control flow, so it doesn't really answer the question. I think using exceptions for control flow is considered less evil in Python than in other languages, although it's still questionable. But best practices votes here are so random that no one knows if it's best practices at all )

no.

Although this is nice and concise, it's an O(nlogn) algorithm, when an O(n) solution is possible.

amazing!

I was also going to mention the lack of need for elifs.

`' '`

is the default for`split`

already, so you don't need to pass it, just use`split`

without arguments.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:

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?

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.

Same problem for Dart:

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

I'm very confused on why that solustion works. Can someone clarify please?

Great solution!!

Iterating one time is orthogonal to using exceptions for control flow, so it doesn't really answer the question. I think using exceptions for control flow is considered less evil in Python than in other languages, although it's still questionable. But best practices votes here are so random that no one knows if it's best practices at all )

yes, this way you traverse the list only one single time

This comment is hidden because it contains spoiler information about the solution

This is almost identical to mine. you could innitially simplify by making s.split(' ') into s.split(). it will automatically split by spaces.

## Loading more items...