Ad
  • Custom User Avatar

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

  • Custom User Avatar

    It is pretty rare to have a best practice be while(true) and conditionally break;

    I get its prettier to read than the next solution but this is a bad habit.

  • Custom User Avatar

    To expand on this, any non zero value returns true, any zero returns false. This means you never need to check if something == 0 in your if statements, you can infer that if it is zero it will return false, and structure the program around that.

  • Custom User Avatar

    The server has a 12 second time restriction iirc. This program takes a really long time to run as others have pointed out, O(n^2). In a simple prompt like this maybe you can get away with it, in more complex prompts getting into the habit of nesting for loops can quickly get out of hand.

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    think if you have a constant double. Say n.12345 where n is the integer part

    std::round() chops off the decimal places giving you n(or n+1 if rounded up)

    by multiplying it by 100 we have n12.345, which gets chopped to n12

    divide by 100 and you are left with n.12

  • Custom User Avatar

    I think the main issue with this Kata is that it is too difficult for an 8 Kyu. Most 8 Kyu Kata are simple implementations of things we don't even consider in day to day life. i.e How to tell a number is odd. This Kata asks you to know/relearn algebra that many new programmers who are just starting may not even be old enough to learn in school yet.

  • Custom User Avatar

    I know you are meming but for any newer coders out there past n = 416 the output won't fit in an unsigned long long(the return type), which is why 416 is the end of the list.