Ad
  • Custom User Avatar
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    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.

  • Custom User Avatar
    • From rule1, what does this even mean?!

      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 becomes 001010 (We count bit's positioning from left to right)

    • What does 'change against' mean? Does it mean swapping, or copying values?

      It means swapping the first 3 bits with the last 3 bits. i.e, 101000 --> 000101

    • What is an 'odd bit'? Odd index? Or is it 1-bits?

      In other words, it swaps two adjacent bits i.e, 101010 -> 010101

    BTW, you've solved the kata, so closing ! ^^

  • Custom User Avatar

    I've found this one but it is the other way around, given the amount of handshakes, return the amount of people.

  • Custom User Avatar

    That was for "difficulty" in the beginning, but i should've removed it when i delete input validations.
    I will change it now.

  • Default User Avatar

    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.

  • Default User Avatar

    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.
    :)

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    Number.isInteger, or Number.isFinite if elements can be floats

  • Custom User Avatar

    x ? x : 0 will coalesce all falsy values to 0. if you want to handle only the -0 vs 0 quirk, id do x === 0 ? 0 : x.

  • Custom User Avatar

    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)

  • Custom User Avatar

    Crikey, NaN ==== NaN according to chai. That goes directly against the IEEE spec for NaN.

  • Default User Avatar

    map(x=>x ? x : 0) as been applied to both operands of the test case to prevent floating point issues.

  • Loading more items...