Ad
  • Default User Avatar

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

  • Default User Avatar

    There are also subtractions. In fact, there is one more addition than subtractions.

  • Default User Avatar

    If this kata is to be an exercise in regular expressions, its description should be updated to indicate that it is not looking for the actual domain in the URL, only a kind of approximation to it.

    Because practically every solution that is currently accepted is incorrect--when using a more accurate definition of "domain".

    For example, most solutions seem to hardcode "www." as being the only possible (optional) sub-domain. So that given the URL "subdomain.domain.tld", many solutions would return "subdomain" as the domain. And given the URL "nested.subdomain.domain.co.uk", many solutions would return "nested" as the domain.

    I scrolled through a few ~pages of solutions, and not one of them would be able to accurately return the domain in those cases. Even the solution I submitted is not complete.

    I understand the intent of the kata as an exercise for regular expressions, but it should be updated to reflect the fact that isn't actually looking for a proper domain (unless my definition of domain is different from everyone else's).

  • Default User Avatar

    Note this won't work if obj is an instance of a subclass of str: in such a case, the 'if' statement would be false and so the obj would returned as a list. Using if isinstance(obj, str) would resolve that.

  • Default User Avatar

    This will raise a ValueError if there's more than 1 ':' in a str "part".

    a, *b = i.split(':')

    would correct it.

  • Default User Avatar

    This fails when code (num) is 0: it raises a ValueError.

  • Default User Avatar

    The non-regex solution fails when code is 0: it raises a ValueError.

  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

    This version is a bit more concise and easier to follow than my previous submission.

  • Default User Avatar

    The main.py file (which contains content I did not create--I assume it executes the code that's submitted) contains a call to xrange(). This causes an error when using Python 3, as xrange() is no longer built-in. Submitting code against Python 2 works, however (since xrange() is built-in for Python 2).