5 kyu
Common Bit Twiddles
278 of 428user5854572
Loading description...
Binary
Bits
Refactoring
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
This comment has been hidden.
Everything's fine with the kata.
This comment has been hidden.
This was a nice way for me to learn more about some of the bitwise operators, thanks!
Very good and challenging kata! Thanks!
This comment has been hidden.
This comment has been hidden.
I think you should edit the description to state that each function must be self-contained; helper functions are not allowed.
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-
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 :)
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.
I made the test fail messages more descriptive
Spot on. Thanks.
This is the first time I'm trying out a little 'anti-cheating engine'. Please let me know if it gives any false-positives.
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?
This comment has been hidden.
This comment has been hidden.
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.
I broke your anticheat easily... See my solution.