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.
Updated my six year old solution. I thought about doing an __asm__ instruction, but considered the many different architectures the code could run on. Found this compiler intrinsic, supported in GCC and Clang. Other compilers may have their own builtins, but this code only runs on Clang so I didn't bother.
This builtin essentially places the assembly instruction for you, based on the architecture, to have the hardware count the bits in a loop, as opposed to us bitshifting around.
My previous code did use bitwise operation as well
But it didn't work as it would generate bunch of random 1 when the loop is higher
This comment is hidden because it contains spoiler information about the solution
You have a hidden allocation here.
for indx, c := range coord
is actually making a copy ofcoord
and iterating it. That's only because you have, c
there. If you remove the second for loop value, it will not copy and you will need to indexcoord
yourself atindx
.Nice. Didn't know that was possible. But keep in mind I believe this causes the regex to be compiled on each function call. It would be better to have the regex compiled in a var outside of the function.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Thank you a lot!
It's Linux x64 NASM, so arguments are always passed in through registers rdi, rsi, rdx, rcx, r8, and r9, with any extra arguments pushed onto the stack. I've been using this reference sheet a lot while learning, this is more detailed instruction reference that's very helpful too.
ASM learner here: how are you supposed to know which register an argument is passed from C?
Oops, the buffer length on snprintf should only be 25.
Best part is it's ironically over complicated code for just two commands.
Hi...
First, do not give up answers in your messages (that's why somebody already flagged it as spoiler, so nobody can now read it if he/she doesn't have already completed the kata. So much for helping people...)
Second, do not post "issues" where there are not. That was a flaw in YOUR code, not in the kata itself. If you have troubles, post a "question".
Third, "iissues" are used when a kata fails completely to execute, or when one can find a flaw in its logic. In either case you can/have to post an issue, but you have to document it too (just an information for future cases). So once again: troubles without demonstration of a flaw in the kata = "question". With demonstration = "ISSUE".
Fourth, when you stumble on a kata that has already lots of completions, there are far more chances that the flaw is in your ocde, not in the kata.
Fifth, ...but be aware that very old katas might contain some flaws that can't be corrected anymore, unfortunately... (test cases are locked after 500 completions), so if you find already 15 times the same isue in the discourses, it's useless to post it again...
With all of that, I hope you''ll have in mind some useful things to wander on CW and to use it the better wy (for everyone ;) )
Happy coding ;)
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Loading more items...