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.
Switch to C :D
(/s)
Note to self: RTFM...
Can someone explain me why Input 100 must return -1 instead of 10 (010)?
You are thinking of the value that is generated for that input, but that position may be used by the number generated by a later member of the sequence.
Bear in mind that 1) the array has to be in order and 2) there are no repeating positions.
Heck I missed the isdigit() utility, it might have made my solution much simpler...
The only improvement for your solution: rather than using magic numbers to convert char to int, You can literally do ISBN[i] - '0'.
This comment is hidden because it contains spoiler information about the solution
Pretty clever, instead of going first through all the arrays, you count for the time by decreasing each customers time by one for each queue...
Only problem is that unused variable at the beginning, it bothers me x)
It, as always, depends. It's C. It lets you do those things. Yes it's unsafe, given you input something out of the given assumptions.
Is it wrong? No, it's in fact one of the fastest solutions out there. Given the specific architecture and resources, is an "elegant" solution.
You want to program a general function for several different cases? Then it's dangerous. Go use Rust. Or use --Wall --Werror.
Full disclosure: I wouldn't do it in my professional career, I program airplanes. That's a hard no-go. But this solution is one inside the C Standard Language, and a good one.
This comment is hidden because it contains spoiler information about the solution
You could encompass the else if directly into the else, in the end they are doing the same (return 0 when the number is 0, which is the same as returning the number itself).
Instead of using C, he just made inline assembly functions (the thing to which C code would be compiled).
It is really just a flex, worst argument against it is that he makes assumptions about the architecture he is using (which for most of them, it's the same)
It's fancy, but it will make a function call and therefore be slower than other functions.
You can always evaluate the expression itself, without the need of creating a branch.
E.g. return (bullets >= BULLETS_PER_DRAGON * dragons);, it will already give true/false.
I'd rather make the casting explicit, but I come from another programming world...