Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
There are also subtractions. In fact, there is one more addition than subtractions.
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).
nvm, chat-gpt said this:
a, *b = ...: This is the iterable unpacking syntax. It assigns the first value of the iterable to variable a and the rest of the values to a list variable b. The * (star or asterisk) is the extended unpacking operator introduced in Python 3.
What the start before the 'b' does?
Note this won't work if
obj
is an instance of a subclass ofstr
: in such a case, the 'if' statement would be false and so the obj would returned as a list. Usingif isinstance(obj, str)
would resolve that.This will raise a ValueError if there's more than 1 ':' in a str "part".
a, *b = i.split(':')
would correct it.
This fails when
code
(num
) is0
: it raises a ValueError.The non-regex solution fails when
code
is0
: it raises a ValueError.This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Ruby:
random tests => duplicate issue, (but only in js) see below, thanks
test added to all languages
No random tests and the solution below may pass but not fit the problem description:
https://www.codewars.com/kata/reviews/5e0e15bd4225f300010c2a9f/groups/5e0eb5644ebc200001b5d8fc
Loading more items...