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.

  • Custom User Avatar

    I'm passing 98 random tests out of 100. My algorithm can't handle an array of 42,000 numbers. Trouble :(

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

    I think that global variables should take initial values between tests, otherwise the tests receive different input data

  • Custom User Avatar

    Bombs do not detonate other bombs! I did not understand from the description.

  • Custom User Avatar

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

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

    I noticed a very strange feature. If you create global variables (not in a function). Then their state persists between tests. I first created dictionaries as global variables, and did not understand what was happening :) This is very strange in my opinion.

  • 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

    Thank you! The task turned out to be more difficult than I expected. Unfortunately, I didn't get it right away because of my very poor English.

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

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

    After reading the discussions and making sure of my code, I found out that not all words have to be in the 1000 word set. And this must be indicated explicitly in the description! But I still can't solve the problem.

    For example, I can return count 5 when I need 15. In doing so, I verified that when I return 5, some of the words are present in the 1000 word set. That is, my code works exactly as I want. And I cannot understand why I am not passing random tests.

  • Custom User Avatar

    I completely agree

  • Custom User Avatar

    Thank you! It was very hard! I've been looking for a solution for a long time. But the solution I found seems to me to be very tricky. 5 lines in total :)

  • Loading more items...