Skip to content

BombDefuser exemplar solution and tests #496

Open
@adauguet

Description

@adauguet

I am trying a to mentor a student on the BombDefuser exercise.

It states:

For each bit in the ID number, starting with the leftmost bit, you will apply the flipper closure to the wires tuple if the bit is a 0 and you will apply the rotator closure if it is a 1 giving the new state of the wires.

To my understanding, this means that I should process the leftmost bit, which the left most 1 or 0.
If my number is 253 (like in the tests), its binary representation is 1111 1101 and I should process bits in the following order: 1, 1, 1, 1, 1, 1, 0 and 1.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions