Ad
  • Custom User Avatar

    If we are supposed to write random_valid_key() and random_invalid_key(), then the kata description should specify that. But that doesn't make sense because we can then write trivial implementations of those functions that will make any solution pass.

  • Custom User Avatar

    In this case, the "random_valid_key" function will need to calculate 43 numeric digits plus 1 check digit. Try using another function within the code to create the check digit and import it into the "calculate_check_digit" function. As I mentioned, I tested the code on Kate and it works without any errors. As for the "random_invalid_key" function, you need to create a key that does not have the check digit in which case it will always return false, if a valid key is generated it will not pass Kata.

  • Custom User Avatar

    Would you please refrain from posting AI-generated answers all over the place, including Github and kata discourses? They are borderline off-topic, and none of them answered any question in a useful way. Just write your own answer, keep it on topic, and eventually use AI tools for proofreading and spellchecking.

    And the problem with random_valid_key and random_invalid_key is in your code and if you cannot see it, no AI will help you understand it.

  • Custom User Avatar

    Still seeing it though. Here is what it looks like when I submit a solution:

    image

  • Custom User Avatar

    I tested Kata, and it doesn't show any errors

    Time: 517ms Passed: 4Failed: 0
    Test Results:
    Access Key Validation Tests
    Test valid access key
    Test invalid access key
    Test list of access keys
    (2 of 2 Assertions)
    Completed in 0.32ms
    You have passed all of the tests! :)

    Function scope: Make sure the random_valid_key function is in the correct scope to be accessed within tests.

    Check that the code indentation is correct. In Python, incorrect indentation can cause problems with function scoping. For example, if the random_valid_key function definition is inside another function or conditional block, it may not be globally accessible.

    random_valid_key after tests: The random_valid_key function must be defined before being called in tests. If the function definition code comes after the test block, Python will not find the function at execution time. To fix this, ensure that the random_valid_key definition is above the test call or within the same code block where it is invoked.

  • Custom User Avatar
    NameError: name 'random_valid_key' is not defined
    
    NameError: name 'random_invalid_key' is not defined
    

    Still an issue.

  • Custom User Avatar
  • Custom User Avatar

    Thanks for the information. Kata has been corrected

  • Custom User Avatar
    1. Assertions are done incorrectly
    2. random_valid_key and random_invalid_key are missing from the tests
    3. The function name that must be written in code is different from the one in description
  • Custom User Avatar

    Not an issue, just a spoiler.

  • Custom User Avatar

    And why is this an issue? Please, don't post solutions like that again, you just spoil the kata.

  • Custom User Avatar

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

  • Custom User Avatar

    I found the kata interesting, but I agree that the explanation could be clearer. I spent a lot of time trying to interpret the logic behind the examples and the relationship between cuts and red cubes. Perhaps including a more detailed visual representation or reviewing the description would be very helpful to avoid confusion, especially for those just starting out. However, I enjoyed the challenge of finding a solution! For those who are still stuck, my tip is: visualize the problem in 3D, this helped a lot in my case. 😊