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.
See above
This comment is hidden because it contains spoiler information about the solution
Right, and to this other one https://www.codewars.com/kata/5a76c830fd8c06283c000068. All basic C++ metaprogramming exercises are similar. I just wanted to create a simple kata to see how the process works and what kind of issues people will encounter before try to add somthing more complex.
Current character's binary representation B.R (Ex:
000001
)Next character's binary representation B.R (Ex:
101010
)We swap the 5th bit of the current character with the 1st bit of the next character. So, first character's B.R becomes
000011
whilst second character's B.R becomes001010
(We count bit's positioning from left to right)It means swapping the first 3 bits with the last 3 bits. i.e,
101000
-->000101
In other words, it swaps two adjacent bits i.e,
101010
->010101
BTW, you've solved the kata, so closing ! ^^
I've found this one but it is the other way around, given the amount of handshakes, return the amount of people.
That was for "difficulty" in the beginning, but i should've removed it when i delete input validations.
I will change it now.
Shouldn't be the case anymore, doesn't have random test cases atm, but later will.
At least a simple 'return 0' won't do the job anymore.
The 'Solutiuon' was passed in by me and seems to work now, if you're seeing that this is not the case, please let me know.
Might as well understood this in the wrong way, as this is my 1st Kata.
:)
This kata does not stand a chance to survive beta. I would unpublish it. You can always ask on Discord if some idea has been done before when authoring kata's.
Apparently it also need a reranking then. A 7 kyu should not have a performance requirement.
That said, only very naive solutions time out. I'm a bit torn on this one. With the mention of the input range, I would rather suggest not having the
performance
tag.Number.isInteger
, orNumber.isFinite
if elements can be floatsx ? x : 0
will coalesce all falsy values to 0. if you want to handle only the -0 vs 0 quirk, id dox === 0 ? 0 : x
.I would add
map(x=>x ? x : 0)
after some basic sanity checks, such as assert isArray and assert every element isInteger (I take it all elements are integers)Crikey,
NaN ==== NaN
according tochai
. That goes directly against the IEEE spec forNaN
.map(x=>x ? x : 0) as been applied to both operands of the test case to prevent floating point issues.
Loading more items...