Ad
  • Custom User Avatar

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

  • Custom User Avatar

    Pairs is outside the function definition because it is essentially a constant. That means it is safe to put in the global space, and that way we aren't reallocating for it constantly. Python, because it is interpretted, can't always optimize stuff like this the way C++ compilers can.

    I probably should've called it PAIRS instead to make it clearer that it was a constant.

  • Custom User Avatar

    Definitely good thing for people to take note of.

    I would include, however, that in this case, it doesn't just not matter, but it would be incorrect.

    When you give a function invalid input, it should throw an error. Catching it unnecessarily can quickly put you in a position where a program fails silently, which is much harder to debug.

    Short version: We don't know what to do with any letter other than these four, there's no defined behavior, so we SHOULD get an error.

  • Custom User Avatar

    Yes! Please, please get used to them. As well as set and dictionary comprehensions. They can do so much for you in such a clear and concise way. They seem hard to understand at first, but when you get used to them you can read them like sentences.

  • Custom User Avatar

    Sure, true, but I think including them is clearer. If the braces got any more cluttered, I'd consider leaving them out.

  • Custom User Avatar

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

  • Custom User Avatar

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