Ad
  • Custom User Avatar

    My issue is resolved.

  • Custom User Avatar

    It was weird as my code with global vars works in VS Code but did not pass tests online.

    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).

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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).

  • Custom User Avatar

    I don't see "don't use global variables" in the instructions... May the instructions should be updated?

  • Custom User Avatar

    "don't use global variables" ?

  • Custom User Avatar

    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);?