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.
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.
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.
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.
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?
This comment is hidden because it contains spoiler information about the solution
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 :-)
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.
Do you know something about references/pointers/aliases?
This comment is hidden because it contains spoiler information about the solution