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.
Code with undefined behavior
This code can take
\*values
from right part, increment, and take next element of array for multiplication.count--
evaluatescount
and then decrements it. In C0
has afalse
boolean value, so the loop will stop whencount
is0
T
will add/subtractsizeof T
to the pointer address, sovalues++
will jump to the next element ofvalues
*values++
will first evaluate*values
and then incrementvalues
. This is being overly clever with operator priority.*(values++)
would have been clearer(*values) * (*(values++))
. Just because it is written left-to-right does not mean it will be evaluated left-to-right. This code just happens to work.Be careful with top voted solutions on Codewars, they are usually garbage
I have no idea how this code works, can someone expalin this to my dumb self...
LOL, seems not quite in the spirit of the kata, but yes this works!
why is this so upvoted?
Adds one space character after the element unless its the last element. But this solution is invalid anyway. It doesn't return pairs but single Strings instead with the comma at the right place so it passes the tests which unfortunately make use of
Arrays.deepToString
instead of comparing the array contents directly.Hi, I undstand everyline but these
if(j != arr.length - 1)
a[i][0] += " ";
can anyone explain it ?
This comment is hidden because it contains spoiler information about the solution
Thanks. The bitwise operator is hard to understand tho.
This comment is hidden because it contains spoiler information about the solution
clever.
this is new to me. I am beginner. can anyone explain this?
this is the only solution that makes sense to me. hahah