Ad
  • Custom User Avatar

    The node is an object so I don't think you can print it but you can try to put it in an array then print it so you can see the length

  • Default User Avatar

    Hi, python user here. I'm totally lost on this, i'm not sure how i'm supposed to extract even a single value. I've read most things about linkedlists and sorts, but if i try something like node.next or something i can't even extract the value. Can someone help me how i'm supposed to even print a single value, that's all i need.

  • Custom User Avatar

    Of course, defining the mod as an external constant is good practice for readability and control :)

  • Custom User Avatar

    It would not make a difference, basic operations on constants like this are optimised away. Try copy the function into a python interpreter, run from dis import dis then dis(f). You can see that the mod is already calculuated in the bytecode.

  • Default User Avatar

    nice one, i believe this one would be the fastest, if only you had pre-calculated the mod.

  • Default User Avatar

    No problem, and sorry for the wall of text - just thought I'd share some useful starting-out Codewars info.

    Good luck with the kata - it's not a basic one, so it's normal to have to work on the complexity a bit. As a small hint, this kata is "intended" to be solved using a certain technique: it can be a good idea sometimes to read the 'tags' in the kata description box to see if you can get any clues on what the topic/technique might be ;)

  • Default User Avatar

    Yes, thanks a lot, i've been actually doing this exercise for like a week now, have had several trials, but had to remake because of complexity. This time i was like almost convinced that there was a bug because the code is so simple, but i totally forgot about resetting the dictionary. Thanks a lot.

  • Default User Avatar

    Hi, first of all welcome to Codewars! As you are new, please know that the Issue tag is only for serious problems with the kata - if you just want help with your solution, please use the Question tag instead.

    I recommend as you get started on the site to read this Troubleshooting guide as 95% of all problems are covered there; in this case my guess is that your solution isn't working due to having a "global variable" d = dict() that does not change between tests.

    Try inserting it into your main function definition instead, and it should work.

    By the way, you can join the Codewars Discord (link on sidebar on the left) if you want help solving/troubleshooting :+1:

    edit: also, forgot to say, please learn to use the very simple Codewars markdown to format your code - otherwise it's very hard to get people to read your code when you post it and you're unlikely to get any replies (no-one is going to read through 100 lines of badly formatted text)

  • Default User Avatar

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