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.
citation needed :)
LGTM
Lmao
):
will be countedwhy
But it is good for a laugh, plus taught me __builtin_popcount
@dust55 The const to function hack does not work on all platforms
What is the first number and what is the second number? Complex numbers are unordered. All solutions coincide with the the reference solution but the order of numbers can be switched because
a + b = b + a
anda * b = b * a
.One possible way to compare floating-point numbers is the following:
(This code is based on the
math.isclose
function from Python.)The values of
rel_tol
andabs_tol
should be carefully selected. Usually,abs_tol
is very small. Something like1e-15
.rel_tol
could be between1e-3
and1e-9
.It's stated that each of
sol[{0 | 1 | 2 | 3}]
is either a "real part [of a number]" or a "coefficient of the imaginary part", so these four seem to be all real; so there are no complex numbers anywhere insol[0] + sol[1] + sol[2] + sol[3] ≅ sum
and(sol[0] + sol[1]) * (sol[2] + sol[3]) ≅ product
are all real.It is specified in the description:
sol[0]
: the real part of the first numbersol[1]
: the coefficient of the imaginary part of the first number (expressed in terms of √-1, more commonly known as i)sol[2]
: the real part of the second number, must not be greater than sol[0]sol[3]
: the coefficient of the imaginary part of the second number, must not be greater than sol[1]Sorry, I'm not quite sure - does that mean percentage difference?
Sure, will fix this issue and the other one later today
Do not test that the returned values are close to the expected values (it is not clear which number is first and which is second). Suppose that the user function returns 2 complex numbers
a
andb
. Then the tests should check thata + b
is close tosum
anda * b
is close toproduct
. I also recommend to use relative errors when checking that two floating-point numbers are close.Do not ask to return a dynamically allocated array with a fixed number of elements. It is better to return a struct with 4 fields (but for this task it is much better to use complex numbers directly):
Does it work now? I've done that type-cast, and reduced the range of
sum
andproduct
in the random tests.It does not fix anything. You need to cast
sum
andproduct
todouble
.Loading more items...