Ad
  • Custom User Avatar

    I was baffled by this signature of the translate method until I realized "Python" here means Python 2.

  • Custom User Avatar

    Most readable of the one-liner solutions I see here.

  • Custom User Avatar

    Fair enough. I love Python, my career revolves around it, but sometimes I just want a little more rigor in the type system! Props to Python 3 for disallowing ordinal comparisons to None.

  • Custom User Avatar

    I'm guessing by "false extending 0" you mean to point out that False == 0? Sure, but take note also that False is not 0.

    My point was just that the description (i.e. acceptance criteria) states "when a is close to b, return 0" (type int) while this returns False (type bool). Python's weak typing in this area makes it easy to be casual. But if you added type annotation to this function and enforced it (say, with mypy or enforce), returning False would be an error.

  • Custom User Avatar

    This returns False if a and b are equal. (I posted a comment in discourse also, since this suggests the tests need tightening.)

  • Custom User Avatar

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