Ad
  • Custom User Avatar

    True, I thought there would be super big numbers to test on, thus forcing us to come up with a more efficient code.

  • Default User Avatar

    input data is presented as arguments to the function, not as global variables
    your globals are yours alone. need them to reset? reset them. though if something resets on each function invocation then it probably belongs in that function, not as a global variable.

    none of this is specific to codewars btw. this is how functions and modules behave in general.

  • Custom User Avatar

    Why is it strange? Is it not how global variables are supposed to work?

  • Default User Avatar

    Once your function has been created, there's no reason to re-create it to use it again.

    from yourmodule import yourfunction
    
    for test in tests:
      assert yourfunction(test) == referencesolution(test)
    
  • Custom User Avatar

    Do I only have to slide when I land on the snake's head?

    Yes!

    Player n wins: Return this after a player reaches exactly 100. The game is finished now.
    Game over: Return this if the game is already finished.

  • Custom User Avatar

    as far as i understand
    if player1 is playing and roll a dies and reach the 100 then player1 wins.
    and even after player1 wins, the Player2 tries to roll the dies we should return "Game over". (because player1 is already won the game!).

  • Default User Avatar

    and a set of the 1000 (plus a few) most common words

    This already hints at that you won't get a perfect translation

    using nothing but your wits

    is also in that direction

    and it is additionally completely on-topic for the problem being solved

    I will further argue that you should not be making assumptions about things that are not promised to you! This goes for all problems. Make sure the things you use are supported by the description or other information. If you make something up you're on your own.

    And I cannot understand why I am not passing random tests.

    If you pick a test case that your code fails for, you can then print out things like whether you tried the right key, and there are probably things that you can print out about why you are choosing a wrong candidate over the right one. Would you for example pick that same wrong candidate yourself, manually? You say that "some of the words are present" but that would also be the case for the correct one, right? So you have to choose between them. Which of them fits better?

  • Custom User Avatar

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

  • Custom User Avatar
    • If I passed one giant string then all solutions will require some kind of string splitting.
    • If I passed as array pairs then solutions will be using arrays.
    • If I passed as an array of some new structure/class (x eats y) then I am imposing my structure on your solutions.
    • If I passed as a Map then user will be blinkered and maybe not consider alternatives.

    Leaving it as is will give more variety of solutions. Good and Bad.

    Bottom line. With 1300+ solution already, I won't be changing this Kata.

    But thanks for the feedback - I will keep it in mind for future Kata :-)

  • Custom User Avatar

    Sorry for your typing. I hope there are many interesting and varied solutions for this Kata, so I certainly do not what to influence/restrict those by specifying input in some particular way. I prefer if each code warrior just does what they think is best.

  • Custom User Avatar

    Do you know something about references/pointers/aliases?

  • Custom User Avatar

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