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.
Issues
Function name should be in snake_case -->
kid_math
instead ofKidMath
Random test should include negative exponent as well
Suggestion
Consider adding assertion message in the random test for debugging, e.g. using
f"Testing base = {a}, exponent = {b}"
as the third argument of assertion.Description can be made language agnostic
This comment is hidden because it contains spoiler information about the solution
normalni shart bersang ulasanmi
specifically for the reason you just gave: sum of nothing == 0 ;)
But when there is two negative elements close to each other, it is considered as no such sum, why should I return 0??? (last example)
Python translation
Python translation
This line
arr[i] = static_cast(rand() * 1.0 / (static_cast(RAND_MAX) + 1.0) * 21 - 10);
can bestd::uniform_int_distribution⩽int⩾ randomNumber(-9, 10)
. In this case you can rid offctime
header and include the mersenne twister engine with random devicestd::mt19937 mt{ std::random_device{}() }
. The final result would be more convenientarr[i] = randomNumber(mt)
Please remove
using namespace std
from Test Cases/Sample Test CasesI tried but it didn't work before. I don't know why. I fixed it.
Wouldn't it be better to write
ExtraMessage("Wrong answer for arr={" + s_arr + "}"
instead ofstring s_arr("Wrong answer for arr={");
Еhank you for your help and advice.
Replace int arr[] with vector notice that int size is redundant.
Done
Replace C headers with proper ones time.h should be ctime either random
Done
I suggest to provide the helper ExtraMessage("Wrong answer for arr={4, -1, -2}") method.
Done
using namespace std
is used nowDone
Is this C translation?
Please re-write it in proper C++ form.
Replace
int arr[]
withvector
notice thatint size
is redundant.Replace C headers with proper ones
time.h
should bectime
eitherrandom
I suggest to provide the helper
ExtraMessage("Wrong answer for arr={4, -1, -2}")
method.This line is not necessary
using namespace std
there's no practical use.Python translation
Loading more items...