Ad
  • Custom User Avatar

    It gives this weird error on the second random test. Don't ask me why.

    Traceback (most recent call last):
    File "/workspace/default/.venv/lib/python3.11/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/json/init.py", line 346, in loads
    return _default_decoder.decode(s)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "/workspace/default/.venv/lib/python3.11/site-packages/codewars_test/test_framework.py", line 112, in wrapper
    func()
    File "/workspace/default/tests.py", line 75, in random_tests
    expected = referance(f"https://www.wikidata.org/wiki/Special:EntityData/Q404.json")
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/workspace/default/tests.py", line 59, in referance
    data = refsession.get(url).json()['entities']
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/workspace/default/.venv/lib/python3.11/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
    requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

  • Custom User Avatar

    You need to put a bit less faith into AI, because it very often gets things wrong. You also need to learn to talk to it properly, because this skill is critical to get correct information from AI. For example, I asked it:

    How many bytes of memory does string "hello" take in Python?

    And it answered:


    In Python, the string "hello" typically takes 49 bytes of memory.

    Breakdown (in CPython 3.11, on a 64-bit system):

    • Base str object overhead: 49 bytes (includes metadata like length, hash, etc.)
    • Each character in a compact ASCII string uses 1 byte.

    So, "hello" (5 ASCII characters) fits in the compact ASCII representation.

    Total: 49 bytes.

    You can confirm with:

    import sys
    sys.getsizeof("hello")  # Returns 49
    

    So while it might get the calculation wrong (49 instead of 49+5=54), it is able to understand a properly asked question and account for many factors affecting the answer. The question you asked was taken out of context (it was missing critical information that it asks about a byte size of a Python object), and AI interpreted it in more general way, considering only characters, because it's the most common interpretation for this kind of questions.

    Using AI is a skill, and it's very helpful to learn how to use AI effectively.

  • Custom User Avatar

    At work, developers constantly complain about clients giving unclear instructions. And now look at this — 90% of Katas fail on random tests because critical info is missing from the task description.

    It’s driving me absolutely mad!
    🤬

    Check out this gem of a task — so confusing even an AI stumbled:

    -- do you see how "hello" is 54 bytes?

    -- That’s a fun observation — but the word "hello" is definitely not 54 bytes. Let’s break it down:
    Each character in "hello" is typically 1 byte in UTF-8 or ASCII encoding.

    😂

  • Custom User Avatar
  • Custom User Avatar

    to make the issue extra clear in case anyone is trying to fix this:

    there is a fixed test mentioned in the description for entity Q42 that expects:

    {'ID': 'Q42', 'LABEL': 'Douglas Adams', 'DESCRIPTION': 'English science fiction writer and humourist'}
    

    but it seems that this wikidata entry was modified since the kata creation, and as per the rules the correct answer should now be:

    {'ID': 'Q42', 'LABEL': 'No Label', 'DESCRIPTION': 'English science fiction writer and humorist (1952–2001)'}
    

    The description should be fixed too.

  • Custom User Avatar

    duplicate of this issue (the label for the Q42 fixed test is outdated)

  • Custom User Avatar

    duplicate of this issue (the label for the Q42 fixed test is outdated)

  • Custom User Avatar

    Memory size, not byte size.

    'Hello':

    Byte size (size of the string in UTF-8 encoding): 5 bytes

    Memory size (total memory occupied by the string in Python): 54 bytes

  • Custom User Avatar

    Will do. Just made a quick edit that includes printing the pattern length, as the python version does.

  • Custom User Avatar

    Thanks, approved!

    I don't know C#, so please check back in a few days to see if there are any issues with it.

    Cheers

  • Custom User Avatar
  • Custom User Avatar

    Is there en version of label? Can't find it

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

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

  • Loading more items...