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.
This comment is hidden because it contains spoiler information about the solution
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.
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.
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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
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
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.
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.