5 kyu

Common Bit Twiddles

278 of 428user5854572
Description
Loading description...
Binary
Bits
Refactoring
View
AllIssues2QuestionsSuggestions3Show Resolved
  • Please sign in or sign up to leave a comment.
  • sipubot Avatar

    This comment has been hidden.

  • sipubot Avatar

    This comment has been hidden.

  • nsticco Avatar

    This was a nice way for me to learn more about some of the bitwise operators, thanks!

  • user5036852 Avatar

    Very good and challenging kata! Thanks!

  • computerguy103 Avatar

    This comment has been hidden.

  • computerguy103 Avatar

    This comment has been hidden.

  • computerguy103 Avatar

    I think you should edit the description to state that each function must be self-contained; helper functions are not allowed.

  • user1358746 Avatar

    I just cant see how to implement truncate without if else or even ternerary, is this even possible? Also the tests are giving poor feedback, I am failing one and passing 18 yet the error is not useful at all, I cant find which test Im failing from the output, I can only guess from my functions-

    • user5854572 Avatar

      That one is a little tricky if you haven't seen it before. Try googling around for some JavaScript shorthand tricks. It is almost always listed on guides like those.

      I have 3 sets of test cases:

      The first set checks to see if you actually got the right answer, and displays an error showing which function call with which arguments are failing.

      The second checks to see that you haven't used any of the blacklisted operators. If you fail that one it should tell you which function is failing the test.

      The last one runs your code in an isolated environment, and will throw an error if your function relies on any other functions. Coincidentally, it will also throw an error if your code naturally throws an error that is unrelated to being dependent upon another function.

      I'm guessing your tests are failing on the 3rd set of tests, because it doesn't give a customized error message. The reason you are passing many others but failing 1 is because the 3 sets of tests run independently of each other.

      As a side note, you can actually kind of fake a ternary operator using a boolean expressions including && and ||; although, it is not required to do so.

      Good luck :)

  • wthit56 Avatar

    The tests don't give much to go on if they fail. No messages, no inputs to retest yourself. Would be really useful to have this kind of thing included in there.

  • user5854572 Avatar

    This is the first time I'm trying out a little 'anti-cheating engine'. Please let me know if it gives any false-positives.

    • wthit56 Avatar

      Would love to know how you're doing the anti-cheat thing. Could you put the code in the test so we can see it, or post it here?

    • user5854572 Avatar

      This comment has been hidden.

    • LDeleuran Avatar

      This comment has been hidden.

    • user5854572 Avatar

      LDeleuran,

      Yes, it is intended that each function should be completely self-contained. While it doesn't sound like you wrote a second function in an attempt to bypass the requirements, I unfortunately don't know how to modify the 'anti-cheat engine' to ensure that secondary functions are not in fact cheats. So my code just assumes that if your function is dependent upon another one, you are cheating.

    • tianshuo Avatar

      I broke your anticheat easily... See my solution.