Ad
  • Custom User Avatar

    Oh!! Nice trick hahaha, I will try that out! Thank you!

    Edit: Alright, with that trick I will be able to debug my code, thanks.

    Edit2: I finally did it!! It was a small rule with straight hands that I wasn't fulfilling. Thanks for your help, that trick allowed me to test one by one and to debug my code.

  • Default User Avatar

    Errr... Did you strech out the "describe.it" thing? You should have the informations printed in the console there (by default, "describe.it" hide the display but it should already be unfold in case of failed test... Taht's weird... :-/ )

    Might be that the information isn't displayet at the right place. Could you check in the upper levels?

    EDIT: Errr f..k, that won't work. The data for the random tests are not of the same type. What I did allow the display only for the fixed tests... :/ It's out of my reach, sorry.

    EDIT²: Now I remember I had the same problem when I did it in Java. I managed the thing by dispalying the hand string in the contructor: it will be called for the creation of the pokerhands used in the random tests. So you won't know which ones are called in the failing test, but at least you'll have a list of all the hands in the random tests.

  • Custom User Avatar

    Thank you very much, but it keeps showing me this:

    Expected: true
    Actual: false

    And not the case being tested in the random part :( Do I have to wait?

  • Default User Avatar

    Job done!

    (and I thought that Java was really THE pin in the ass... But I see that C++ is quite awful too!)

  • Custom User Avatar

    Alright, no problem. First of all if you want to concat two char arrays, you need to use strcat, you will have to #include <string> too.
    Here you go:

    bool FuncName (const char *player, const char *opponent, Result A) 
    {
        char playerStr[256] = "Player hand: ";
    	char opponentStr[256] = "Opponent hand: ";
    	strcat(playerStr, player);
    	strcat(opponentStr, opponent);
    	if (A != B) {
    		std::cout << playerStr << std::endl;
    		std::cout << opponentStr << std::endl;
    	}
    ...
    
  • Default User Avatar

    Errr... not exactly what I needed actually (my bad). So let's say that I have now that piece of code:

    bool FuncName (const char *player, const char *opponent, Result A) {
      if (A != B) {
        std::cout << "Player hand: "+player << std::endl;
        std::cout << "Opponent hand: "+opponent << std::endl;
      }
      ...
    

    I add #include <iostream> at the begining, but I get that error message:

    -isystem /runner/frameworks/cpp  error: invalid operands to binary expression ('const char *' and 'const char *')
        std::cout << "Player hand: "+player << std::endl;
                     ~~~~~~~~~~~~~~~^~~~~~~
     error: invalid operands to binary expression ('const char *' and 'const char *')
        std::cout << "Opponent hand: "+opponent << std::endl;
                     ~~~~~~~~~~~~~~~~~^~~~~~~~~
    2 errors generated.
    

    Next step??

  • Custom User Avatar

    Oh, thank you very much!! :D
    C++ translation of what you need (you will need #include <iostream> in case you haven't got it):

    (There is no need for curly brackets as it is only one instruction per if else statement.)

    if (A != B)
      std::cout << player << std::endl;
    else
      std::cout << opponent << std::endl;
    

    Both player and opponent must be either "char *" or "std::string".
    I would appreciate a lot if you could edit the kata, thank you for your time!

  • Default User Avatar

    Actually, if I give you the random tests, seeing the way they are done, you can cheat them very easily. 'Not saying that you will, but...

    If you can provide the code that is necessary to print strings in the console, I could maybe edit the kata... :o

    let's say you have two strings to print: player and opponent... ;) Actually, if you provide the equivalent of this, it would be even better:

    if A != B then print(player) ; print(opponent)
    

    Keep in mind I know nothing in C++, so do not forget brackets or small "teeny-weeny-shitty pieces" like that if they are needed! ;)

  • Custom User Avatar

    No problem, thanks for the reply anyways.

    Yeah, I've noticed that the cases being tested are not displayed in C++ (but I managed to pass the sample tests reading poker rules and hand rankings thoroughly over the internet), they do in other languages, though. Is there any way for me to see the random tests? By private message or something like that (to build an unit test on my own). I believe it is safe to say that the tests are common in every language, am I wrong? If they are not I will go and ask those guys, because I really want to complete this kata :D

  • Default User Avatar

    Don't know anything to C++, sorry. You'll have to wait for FrankK or nomennescio who did the translation (you can try to post a reply to one of his messages below, but seeing how badly the messages alerts work on CW, there is no garanty of answer...

    Sorry...

    Note: this is a problem of conception of the kata in C++ (and other languages too if I remember well): the assertion is made on the result of the comparison, without displaying the input before that (but you knew already that, I guess). You have strictly no access to the hands strings, for now...

  • Custom User Avatar

    Thanks for answering!
    C++ :D

  • Default User Avatar

    first things first: what language?

  • Custom User Avatar

    I am no Poker expert, but I have read and I have implemented every rule of poker and I think my hand ranking system is fine, but some cases in the random part don't pass with my code.
    I have followed the wikipedia article linked in the kata, and the list of poker hands in the lower part of that page.

    How can I know which random case is failing? Just to fix that poker rule I am not fulfilling. The only info I get is:
    random_compare_poker_hands
    should_pass_all_the_tests_provided
    Expected: true
    Actual: false

    Thanks in advance.