Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
True, I thought there would be super big numbers to test on, thus forcing us to come up with a more efficient code.
I'm passing 98 random tests out of 100. My algorithm can't handle an array of 42,000 numbers. Trouble :(
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.
I think that global variables should take initial values between tests, otherwise the tests receive different input data
Bombs do not detonate other bombs! I did not understand from the description.
Why is it strange? Is it not how global variables are supposed to work?
Once your function has been created, there's no reason to re-create it to use it again.
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.
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.
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.
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!).
This already hints at that you won't get a perfect translation
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.
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?
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.
I completely agree
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...