6 kyu
bit "Wise" #1: XOR-cism
748 of 774bkimmel
Loading description...
Algorithms
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.
It's a little late, but wouldn't it be better if the exercise took an object
x = {a: 1, b: 2}
, changedx.a
andx.b
and was called for effect? That would get rid of a lot of the troll solutions.This comment has been hidden.
This comment has been hidden.
Yeah, see the comments above... originally, I made it so you only had access to the bitwise operators through a machine... but it felt a bit contrived, so I just left it as DIY with some encouragement to use the bitwise ops.
This comment has been hidden.
I agree with jsoverson -- I actually didn't understand what you wanted from the description, and the simple return statement is certainly the easiest way to achieve what turns out to be what you wanted. This kata should definitely have a goal that's more than just that if you want to teach the bitwise operators.
I'm thinking 5 kyu for this just because bitwise operators are an obscurely used language feature.
seems about right.
Thanks for the suggestions, but I think both of those throw false positives and/or are easily hacked around in a "source-scanning arms race". I'm enjoying this site because people are generally cool and just follow the code...at the end of the day, if someone wants to cheat the kata, they are just cheating themselves.
If you like this, drop a comment here and I'll continue making some more in this bit "Wise" series.
Seems a bit contrived and the framework you create hides away the actual bitwise operators, which works against what you are trying to teach here. I think a better approach would be to find problems that are naturally best solved by bitwise operations and then make a kata for that problem, giving a hint in the description that the bitwise operator could be useful.
I agree with constablebrew's comments. I also wasn't really sure what needed to be done. I do like where you are going with this though and think that this could be a good series of kata.
Also I took the liberty of updating the description so that it uses syntax highlighting.
This comment has been hidden.
Would it be possible instead of undefining some functions, defining allowed functions? Well, that's a bit what you did, but it DOES look awkward, even though I do like the principle...
OK, I changed it to an honor code - based kata. No more contrived object thing-y. Does this work better?
Maybe you could parse the user's function source to look for any var statements, preventing them from using the store-and-stop technique.
Here is a quick example. (Probably not very effective, but a decent starting point for what I am thinking.)
if(JSON.Stringify(solution).indexOf('var ') > -1) throw 'Sorry, "var" is disabled.';
One problem I thought of that would almost require a bitwise operation would be to take two strings as input and then return a single string that is the xor of each character of the two strings.
Since this is a JavaScript only kata you could check the solution code and see if it contains any required characters.
for example:
Just saw the latest version. I feel like the whole honor system thing will just A: invite people to cheat even more, B: it makes the experience a bit odd because your not really able to code within the comfort of your own coding style.
I actually think its ok if some users don't use the bitwise operators. For me the spirit of Codewars is to allow users to solve a problem in the way that they feel comfortable with and represents their style of solving problems. After they solve a kata they see the other solutions and often have an ah hah moment where they see how much better/easier/succinct/etc it could have been solved. So IMO, the fact that you are emphasising bitwise so much within the kata name & description means that most will probably take it upon themselves to try to use bitwise operators, and those who don't - that's ok - they will still probably learn something anyway.
"most will probably take it upon themselves to try to use bitwise operators, and those who don't - that's ok - they will still probably learn something anyway."
Yeah, and that's the whole point anyways... a couple comments isn't going to stop someone from doing whatever they want to do, so I'll probably just leave this one as is..
.. took out the "honor code" stuff, so people don't feel bad if they can't figure out how to do it bitwise.
Looks good. BTW very clever idea with the HINTS approach.