Ad
  • Custom User Avatar

    I feel exited every time I'm able to look at other people solutions on here, sometimes I spend hours testing other people code and mession around with it, such a grate opportunity.

  • Default User Avatar

    I felt the exact same way! After submitting my solution (which had taken several hours) triumphantly, I stared in disbelief at the one-liner at the top. And as well as scrolling through all of the other simpler solutions.

  • Default User Avatar

    Hah, every time I solve a kata I feel totally embarrassed when looking at the other solutions, especially in this case :) Man, I suck at these kind of problems...

  • Custom User Avatar
  • Custom User Avatar

    This code may work incorrectlly on some inputs.
    For example:

    str = "12345678912345"
    ~~str // 1942903641
    

    This happens because bitwise operations convert it arguments to 32-bit integers. In this example binary representation of number in str is more than 32 bit, therefore it is truncated.

    So you should use this code only, if you are sure, that all numbers that you pass in your function fit 32-bit.

  • Custom User Avatar

    You're welcome.

  • Default User Avatar

    Nice kata, I enjoyed, thank you :) Please more "Design Pattern" katas!