Ad
  • Default User Avatar
  • Custom User Avatar

    I tried to do something similar,

  • Custom User Avatar

    Briliant :) smartes evever . Everyone try iterate and caluclate and there is the betyfull bitwise

  • Custom User Avatar

    << is bitwise shift left; that's basically multiplying by the powers of 2:

    • << 1 == * 2**1 == * 2
    • << 8 == * 2**8 == * 256
    • etc.

    Similarly, >> is bitwise shift right; which is (floor)dividing by the powers of 2:

    • >> 1 == // 2**1 == // 2
    • >> 8 == // 2**8 == // 256
    • etc.
  • Custom User Avatar

    I like the simplicity of the solution. It's a rare case where using "magic numbers" and manually writing out each of the possibilities (instead of a loop) is actually okay and still quite readable.

    One small suggestion: consider using bitwise | instead of +=. I think the result would be just as readable.

  • Custom User Avatar

    I tried to find where in the kata is the issue you are trying to mark here, but failed. Every mention of (2^200) ^ (2^300) results in 6 as the last digit. Can you please clarify what needs to be corrected? Or if there is no mistake anywhere in the kata, please check this issue as resolved.

    Update: Okay, I think I found and corrected it (it was in Python-specific examples). Please mark this as resolved if satisfied.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution