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
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
The break statements are not needed and can never be reached.
The break statements can never be reached and are not needed.
I just didn't want to assume, in case you didn't mean it as a question.
Thank you, too!
I see you're 2 kyu in C so I'm not sure if you're really asking.
There is no guarantee regarding which side of the while statement is evaluated first. The order is undefined. It is up to the compiler to choose, and apparently the same compiler might choose a different order for different runs. My solution is wrong if the left-hand side is evaluated first. In that case the last position in the array will get the second to last multiple value, and the last multiple will be skipped.
Since count is of type size_t, I think the format specifier should be %zu instead of %d.
Undefined behavior since I both decrement n and read n in the same statement, and the order of evaluation is undefined. I could have instead performed the decrement operation in the while condition, since the condition will be evaluated before the rest.
Good to know. Thank you!
This is the top one for me: https://www.codewars.com/kata/reviews/5d67ef0f8e41b60001c781db/groups/5d6a8e3ab5ed590001d18f30
Edit: Nevermind. I just looked up asprintf(). I didn't know it prints to an allocated string. Thanks.
Don't most of the C solutions (those not dynamically allocating memory) lead to undefined behavior since pointers to arrays of automatic storage duration are returned?