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.
My issue is resolved.
it's not weird, it's because on VSC you do only one single test, so you don't actually see there is a state that is shared between different calls.
Best practice: as B1ts said, don't use global vars (unless you know exactly what you do and how to use them).
How about not using global vars at all? That's the easiest fix. An alternative is to reset all global variables at the start of function.
It was weird as my code with global vars works in VS Code but did not pass tests online. Can you recommend a good article to read how to use global vars correctly? Thanks.
Nope. Anyone can use global vars, but only if they know how to use them correctly. Problems with global vars aren't under the "responsability" of the kata/author, but under the reponsibility of the users (who do not know how to code properly with global vars, in that case).
I don't see "don't use global variables" in the instructions... May the instructions should be updated?
i just tried the second solution, in timed out
i literally copied a solution and it didnt work, execution timed out.
i tried my solutions but i was slow for large number like 9999999999. then i upgraded it but random number were bigger (1003427533368395383) and my solution couldnt kepp up, so frustrated i check the solution (i was on the right path but i was missing some detail) and i tried it, and it failed with a even larger number (4802419968590657004)
just to know the random test isnt even random, it generate the same big number over and over
thanks man, didnt think about that
"don't use global variables" ?
its happening something strange, my code seems to work, i pass the test but when i submit it, it fails the same layout as the test. it doesnt make sense tho.
i logged the input field so i know they are equal
My C++ solution compiles and passes tests, so kata setup seems to be OK. I believe that you either did not stick to the requested method signature, modified it, or left it empty and implemented your solution in some other class/method/function.
Does your solution implement
static std::string SumOfDivided::sumOfDivided(std::vector<int>& lst);
?main.cpp:44:22: warning: comparison of integers of different signs: 'int' and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for (auto i= 0; i<prime.size(); i++){
~^~~~~~~~~~~~~
main.cpp:45:26: warning: comparison of integers of different signs: 'int' and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for (auto j= i; j<prime.size(); j++){
~^~~~~~~~~~~~~
main.cpp:53:22: warning: comparison of integers of different signs: 'int' and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for (auto i= 0; i<prime.size(); i++){
~^~~~~~~~~~~~~
main.cpp:54:26: warning: comparison of integers of different signs: 'int' and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare]
for (auto j= i; j<prime.size(); j++){
~^~~~~~~~~~~~~
main.cpp:66:20: warning: unused function 'SumOfDivided' [-Wunused-function]
static std::string SumOfDivided(std::vector &lst){
^
5 warnings generated.
/tmp/main-1d7c7a.o: In function
sumOfDivided_Tests::Fixed_Tests()': main.cpp:(.text._ZN18sumOfDivided_Tests11Fixed_TestsEv[_ZN18sumOfDivided_Tests11Fixed_TestsEv]+0x5c): undefined reference to
SumOfDivided::sumOfDivided[abi:cxx11](std::vector<int, std::allocator >&)'clang: error: linker command failed with exit code 1 (use -v to see invocation)
can't understand whats wrong, it worked in my editor. i understand the first 4 warning but not the 5th