-
-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BombDefuser exemplar solution and tests #496
Comments
It can be what we choose it to be. Do we want to update the instructions or the implementation? The right-to-left implementation is a bit easier I think, right? If so, it might be best to update the instructions as we don't want to have students implement a very complex solution.
Aha, this must be why the exemplar solution's implementation still passes the tests. We should add a new test that would fail with an invalid implementation. Would you be willing to submit a PR to fix this? |
The right-to-left implementation is indeed a bit easier, using In both cases, instructions should mention to encode on eight bits, just to be sure students do not forget some Note : the I am open to submit a PR as soon as we decided where to go 🙂 |
Also, sorry for creating this issue in the wrong repo. Could you please transfer it to exercism/swift? Thanks! |
These are the exercise's prerequisites:
With just those prerequisites (and their transitive prerequisites), I don't think we can expect the user to know how to do bitwise manipulation. Similarly, the exercise uses the Option 1:
Option 2:
|
You are right, bitwise operators are too complicated for a beginner. Actually there are only explained in one the last chapter of the Apple Swift book. Are you suggesting to completely replace |
I am. |
OK great. Will work on the PR then. |
I've just completed the exercise myself and was confused by the description to start with the leftmost bit. Checking the bits in Calculator.app gave me the clue to my misunderstanding. If you visualize the binary representation as an array, the first bit starts at position 0 and grows to the right. However the string representation shows the Least Significant Bit (LSB) on the rightmost side. @paiv mentioned the same observation in #493. I just wanted to +1 this conversation. 😄 |
I think it would be nice to treat the issue as a typo als long as the exercise isn't thorougly reworked. That would certainly prevent some confusion - as I just had, too ^^ |
I am trying a to mentor a student on the BombDefuser exercise.
It states:
To my understanding, this means that I should process the leftmost bit, which the left most
1
or0
.If my number is
253
(like in the tests), its binary representation is1111 1101
and I should process bits in the following order:1
,1
,1
,1
,1
,1
,0
and1
.In the exemplar solution, the implementation performs:
if bits.isMultiple(of: 2)
. But that is checking the rightmost bit, not the leftmost.What am I missing? Is this an error in the implementation? Or in the instructions?
Fun fact, the
113
number (used in tests) is working in both directions... leading to some confusion debugging all this.The text was updated successfully, but these errors were encountered: