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.
OP solved it, closing
Probably truth is in the middle.
Knowing how to implement something without built-in functions is important from one hand, but from other hand is crucial for professional programming to know language library for fast-usage of such "ready-made" functions.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I don't think so. It teaches you how not to invent the wheel by utilizing existing functions.
I thought so too, but notice if the number is < 2, it'll only iterate twice before it reaches that statement.
Hu, though there was effectively a problem: the random generator could create negative numbers. I fixed that (this does not happen in the other languages).
Well, my dear... Your code is actually wrong. Because of this:
EDIT: well, actually no, it's just totally wrong, in fact. It seems it passes the tests only by chance. Now that you can see the other answers, you'll be able to figure it out.
Mmmmh... that's weird.... Paste your code (with the spoiler flag), please
seriously...? :o
93 -> 9+3 = 12 => not multiple of 9...
@dominikzaq Now it's because of an error in your solution.
Thanks for pointing this out... The problem is solved for the C version, for (big) random numbers where the number of occurences of '1' is greater than 63, we pass. I just re-tested again. Could you confirm?
As I can see, nothing has changed. Still 100 random bits in C, C++ and Java. And long is 32 bits in C here but even 64 may not be enough sometimes.
The tests now don't expect answers that exceed the
long
range, so I believe the question has resoved itself.Btw, there's 64-bit integer type called
long long
(or__int64
, orint64_t
with#include <stdint.h>
)I don't understand your question..
Loading more items...