Ad
  • Custom User Avatar
  • Custom User Avatar

    Even numbers can't disappear out of nowhere. Your code is wrong.

  • Custom User Avatar

    .

  • Custom User Avatar
    • Testing for 'tHese guIdElineS aRe deSIgneD tO Be CompAtiBle wItH joe cELKO’s sql prOGraMming StYLe boOk' and 'These guidelines are designed to be compatible with Joe Celko’s SQL Programming Style book' being the same base string
    • Testing for 'tHese guIdElineS aRe deSIgneD tO Be CompAtiBle wItH joe cELKO’s sql prOGraMming StYLe boOk' to be actually random

    sample: tHese guIdElineS aRe deSIgneD tO Be CompAtiBle wItH joe cELKO’s sql prOGraMming StYLe boOk

    Expected: true
    Actual: false

    for sample test case.

    Also I am not pretty sure if my code does what I meant.

    std::default_random_engine prg; // prg stands for pseudo random generator 
      std::uniform_int_distribution<int> int_distribution(0, 9);
      
      for (int i = 0; i < x.length(); i++) {
        int random = int_distribution(prg);
    

    this was meant to give random number every iteration, and therefore create random case.
    But when I recompile my program I see, that in every single compilation those numbers, are exactly the same. Like drawing them happens only one time. Therefore my "random case" is random only for first compilation, and then it looks exactly the same after another compilations. At least it looks like in my OS - Mint, GCC 5.4.0

    phh, I guess I have to find another way to generate "random" numbers ;]

  • Custom User Avatar

    Do you have some detail on the test results you're getting? What's failing specifically?

  • Custom User Avatar

    I don't think I might explain it better than dingle: would you consider random to return exactly the same string, all lower- or all upper-case?

    They would all be correct results, but that is not how you test the function.

  • Custom User Avatar

    Check this about the code markdown.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    I have same problem, the code works fine in my Python IDE but this test makes it impossible to get through. The test answer deletes some of the evens!

  • Custom User Avatar

    after 3 months it is still broken ;<

  • Custom User Avatar

    hint:

    1. either sum up the smallest values first for better precision, then you don't need temp
    2. or stop after temp < sum * std::numeric_limits::epsilon.
      Any further term wont increase sum.
  • Custom User Avatar

    Thank you so much for your reply! So there is no reason to reivent the wheel trying to write some code on your own, which have same functionality as this already written and saved as functions in language libraries, right? I gotta trust that if there is built-in function it is most efficient and most safe for all purposes, is that correct?

  • Custom User Avatar

    Hi,

    Yes, I think it's a good idea to use functions from a language's "standard library" whenever possible in order to avoid mistakes, performance issues etc. Once you learn them you can also save time and communicate better with other people who are familiar with them.

    I believe the code in our solution is more readable, more concise and less error-prone. Notice you can read it almost as an English sentence, compared to low-level "mathematical" language in your solution. It becomes important when you read and maintain a large code base.

    In summary, it's a good idea to operate on a high level of abstraction. Think about higher-order functions in functional programming or classes with their public methods in object-oriented programming.

  • Custom User Avatar
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Loading more items...