5 kyu

Digits

26 of 165RealSup
Description
Loading description...
Algorithms
  • Please sign in or sign up to leave a comment.
  • AmirTallap Avatar

    I just wanted to say thank you for the author of this kata, took me 3 days to solve. And enjoyed the struggle. Thank you sir for the great work.

  • ahmet_popaj Avatar

    Quite challenging kata in fact, well done.

  • DeNöff Avatar

    In the example I play 1 game, in the test do I play multiple games? If I just return {1,2,3,4} is there 1:5040 chance to pass?

  • ixian Avatar

    Nice kata, but difficult.

  • HuxIsMe Avatar

    can someone explain the desired input and output to me again with another example?

    Im not 100 what my code should be doing?

    should it just be returning 'matches' when a value is in the correct place?

    thanks

  • KonstantinDosaev Avatar

    When I click the attempt, I get more than a hundred, but the array from the error works fine in VS. The test also goes perfectly.

  • hugoferreirj Avatar

    My code still needs to be refactored, but i'm getting time out at the 500 tests all at once. My code seems to work properly finding the answer in less than 17 attempts, but i think testing 500 sequences all at once it's causing the problem. Any hint on how to solve it?

  • goldenratio161 Avatar

    very encouraging kata

  • Arturas1989 Avatar

    Interesting kata :) Maybe you would like to make a kata with 100 digits ? :D

  • MistyCelesteDev Avatar

    I really don't understand what I am supposed to to in this exercise.

  • alexandru.popa Avatar

    The tests in C# are bugged. E.g. the code is 2463, I return 0000 and next input is matches = 1, which should be 0.

  • Awesome A.D. Avatar

    Python Translation ready for review.

  • jonjames1986 Avatar

    I'm using C#. I'm not understanding this. It says it's giving me the number of matches I have. I assume this is the number of indexes of the array that I create that match the indexes of the answer array, is that right? So, if the code array is {2, 4, 6, 9} and I return an array {2, 3, 5, 7} it will give 1 as the answer? So I then have to figure out which index matched and then change the others?

  • JannesCoded Avatar

    I dont know why but the tests are not working in the right way. I get matches where there are no matches and otherwise no matches when there correct. Try to solve it in C#

  • JohanWiltink Avatar
  • Blind4Basics Avatar

    Hi,

    • JS: is the user supposed to track when the game changes the code to find as well? That's not documented
    • there is a global log array in the solution setup. Not described => useful? essential? useless?

    Question: I have to say, I don't like the general setup with the function. There is state involved here. As discussed below, it would be far more sensical to work with instances, one per code to find. Did you just update the kata to go from classes to functions?

    Cheers

  • dfhwze Avatar

    javascript: unlike other languages, we do not get a function to call to verify our guess in the solution setup. Did the way the user needs to interact with the kata got updated for JS only? If not, could you add the function call to the solution setup?

  • ParanoidUser Avatar

    Some other Java caveats:

    1. Class should be structured in a way to hide all internals from a user and prevent hacking (example - https://www.codewars.com/kata/reviews/63a0887b1e15f60001a25cc8/groups/63d47f8a65436000010be67e). This can be achieved through class composition, instead of inheritance.

    2. As the problem states code consists of four unique digits (from 0 to 9). In general, this requires more strict input validation (codes like 3333 should be denied to check). Example - https://www.goobix.com/games/guess-the-number/

    3. Lastly, the algorithm currently implemented gives the wrong answer 1239 when the guessed number was 1237, or answer 9410 for 7014.

  • ParanoidUser Avatar

    In Java, it's a bad practice to mix the main code with the test branch. As most of the time, test libraries (like JUnit) are scoped to the test level, and the main code won't compile.

    A better approach would be to have a separate Helper class in the main branch to give match hints. An instance of the Helper class will be initiated in tests and passed as an argument to tryToGuess method.

    Here is a reference to how it's done on a similar challenge - Guess the number!

  • Voile Avatar

    I find the kata unnecessarily focused on being adversarial to the AI rather than being optimal in our guesser:

    • myDigits and TryToGuess should be instance, not static. Static would mean that we can modify myDigits while TryToGuess is being active, which doesn't lead to cheese because of how CheckAI is implemented (it breaks after ~40 attempts), but is still a red herring
    • Speaking of the above, myDigits shouldn't even be a instance field at all, because it can then be turned into a property, and stops being a constant, again, another massive red herring
    • Is it even necessary to provide our own digits? Can't we just have the player and the AI guess the same digits? We're not trying to be adversarial to the AI after all (hence why all of the above will be attempted, even though they're all irrelevant), so it's only natural to not letting us provide our own digits. Besides, the AI is random in its guessing as well, so it doesn't quite matter
  • Voile Avatar

    Setting any of the values in myDigit outside 0 - 9 will break the actual tests (because of how AI guesser is implemented), even though it is already checked in InputCheck and should not break thereafter.

    Also, some solutions are taking the assumption that you can passing in invalid solutions to PlayerTest.Check (values outside 0 - 9, or non-unique values). This is not specified and should be mentioned in the description because it will affect the behaviour of the guesser.

  • RealSup Avatar

    This comment has been hidden.