Ad
  • Custom User Avatar

    ASCII is a codec with 128 characters, from 0x00 through to 0x7F, inclusive. It's a 7-bit standard.

    Yet, the Python test at the very least assumes that chr(255) is valid input; that makes the input require an 8-bit codec. It's not ASCII, so I had to assume Latin-1 (ISO 8859-1), which is a superset of ASCII.

    Please correct the description.

  • Custom User Avatar

    Very satisfying to finish this, a tip for anyone stuck on the fibonacci sequence: read the instructions for this kata VERY carefully.

  • Custom User Avatar

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

  • Custom User Avatar

    The ~ operator is a bitwise operator, without going into to much detail, it simply inverts the binary bits of the expression in front of it. This is from the mozilla docs: 'Bitwise NOTing any number x yields -(x + 1). For example, ~-5 yields 4.'

    pin.indexOf('.') will return a -1 if the '.' is not in the pin. -1 is considerly a falsy value, so by using the bitwise NOT operator (~) on -1 the result equates to ~-1 = -(-1 + 1) = 0. And by using the logical NOT operator (!) it inverts the falsy value of 0 into a truthy value of 1.

    !~pin.indexOf('.') could be very easily replaced with something more readable like !pin.includes('.').

    I hope this makes sense.

  • Custom User Avatar

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