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

  • 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.

  • Custom 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 ;)

  • Custom 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)