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.
indeed, iBits+2 instead of n+2... but i dunno why i even did a malloc instead of just a fixed sizeof(int)*8+2 byte array or something...
Resu can become unnecessarily huge for large values of n.
I guess great minds think similarlly ;).
That's really clever, but it's undefined C (that is, side-effect operations with binary operations yield undefined effects). And the strict defintion of "undefined behavior" means allowing the compiler to do anything it chooses.
cuz it looks beautiful!
looks elegant but inefficient indeed.
This comment is hidden because it contains spoiler information about the solution
Your array without
-199
:Your array without
196
:q is obviously smaller when removing 196. I have no idea why your excel is giving you the wrong numbers. It's entirely possible that your implementation in excel is incorrect, or maybe excel is running into some kind of overflow error. Your values of q are obviously incorrect, though. You are dividing the product of the array by the sum of the array, with very few exceptions (and this array does not fit any of the exception criteria) this will produce a q value greater than 1, but your q values are very close to 0, and you can manually do the sums and products yourself to see that the q values you should be producing for this particular array should be very large, and so your q values are far from correct.
After looking at your code, you may want to pay attention to the data type that you use to hold your product total values keeping in mind that the product total will be very very large in some cases like the above example.
This comment is hidden because it contains spoiler information about the solution
my passing python solution says 196 and also what you say isn't reasonable after reading the instructions
For C++, I honestly think the random tests have a bug. For example, for this list
The test harness says the answer should be to remove "196" whereas my code says "-199", which according to Excel, is the smaller q value (1.0269E-140 for -199 vs 1.4917E-140 for 196).
This comment is hidden because it contains spoiler information about the solution
This appears to have NOT been resolved. For n = 63, there an overflow even with the C unsigned long long type. For that series, the last two numbers overflow:
I recommend stopped at n = 62 (this would also correct the bogus range of the "High Performance" tests to not exceed UCHAR_MAX).
good tip.
LOL -- I made the same mistake: "i < 0" for size_t will always be false... (what saves you is the i >= board.size() check)
Loading more items...