Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Thanks for your feedback! I thought my idea was a bit more innovative. So, I think I will unpublish this kata.
The kata and the description is just a thinly disguised polynomial root finder, which has been done since a long time ago: e.g this
Rounding/truncating a root makes no sense, as it hits all kinds of floating point errors while also disregarding which value is closer to the real value. What if two nearest values around a root quantized by the same decimal places have the same absolute different between 0? (say,
bolzanos_theorem('4*(x+0.5)**2', [-1, 2], 0)
, which hasf(0) = 1
andf(1) = 1
)? What iff(0) = 100000
butf(1) = 0.000001
?What if the root is exactly one of the quantized values (such as
f(0) = 0
)? Then the value will either be a strict underestimate or overestimate (or (semi-)randomly) based on how the root is searched, and being at the truncation boundary means sometimes the code will just gives you the wrong result because it didn't find the exact value, and truncated-0.0000000000001
down to-1
.tl;dr Please use proper floating point testing and just use
test.assert_approx_equals
for this.This comment is hidden because it contains spoiler information about the solution