Ad
  • Custom User Avatar

    I did the same and it was very fun ;)

  • Custom User Avatar

    And for me..

  • Default User Avatar

    At least, we've tried :)

  • Default User Avatar

    Here is an adapted version of the JS snippet:

      
        private static char print(String piece, int owner) {
            int code = 0x2654;
            if (owner == 1) {
                code += 6;
            }
    
            switch (piece) {
                case "pawn": code++;
                case "knight": code++;
                case "bishop": code++;
                case "rook": code++;
                case "queen": code++;
            }
    
            return (char) code;
        }
      
    

    Works on my local environment.. If this works for you, then Unnamed is right - this is a bug on Codewars. You can report it as not being able to put unicode symbols in the source code.

    And again - thanks for your effort!

  • Default User Avatar

    I haven't created any Katas, so I don't know the limitations with encoding and everything.. But for my local tests, I simply do this:

      
        private static char print(String piece, int owner) {
            switch (piece) {
                case "pawn":
                    return owner == 0 ? '♙' : '♟';
                case "rook":
                    return owner == 0 ? '♖' : '♜';
                case "knight":
                    return owner == 0 ? '♘' : '♞';
                case "bishop":
                    return owner == 0 ? '♗' : '♝';
                case "queen":
                    return owner == 0 ? '♕' : '♛';
                case "king":
                    return owner == 0 ? '♔' : '♚';
            }
            throw new RuntimeException("Unhandled piece!");
        }
        
    

    The file is saved as UTF-8.

    If this doesn't work for you, then probably there is something with encoding of the source code, or the console output.
    Thanks for trying this!

  • Custom User Avatar

    In the output, how about using chess unicode symbols instead of simple letters? (at least for Java; I didn't see the output for other languages)

    Here is how they look: ♔ ♕ ♖ ♗ ♘ ♙ ♚ ♛ ♜ ♝ ♞ ♟

  • Default User Avatar

    Well, as long as you're aware of the situation, it's ok :) Thanks for your reply!

    Just in case: for my local tests, I've used JUnit parameterized tests (https://github.com/junit-team/junit4/wiki/parameterized-tests).

  • Default User Avatar

    Wow, this kata is great. Solved it in Java.

    Do you think it would be possible to show all the failed tests? Meaning that there is no need to interrupt tests if there are some failures.
    Because this is what happens now:

    1. I post a solution.
    2. There are several failed tests shown in the output.
    3. I fix all of them and post a new solution.
    4. All previous test are now green, but..
    5. A few more failed tests are shown, basically new use-cases appear.
      If I had seen all the failed tests beforehand, it would have been a bit easier to come up with better algorithms.

    Other than that, it was SUPER fun. Thanks a lot!

  • Custom User Avatar

    Great Kata. Maybe you could create a series? "Ranking Poker Hands" -> "Sortable Poker Hands" -> ...
    If not, you could just mention "Ranking Poker Hands" in the description so people can start from there.

  • Custom User Avatar

    The Java version doesn't work. Even if I attempt with a simple "return 0", I get an exception:

    Error: Command failed: javac -verbose -cp /home/codewarrior -d /home/codewarrior -sourcepath /home/codewarrior -cp /usr/local/groovy/lib/junit-4.12.jar:/usr/local/groovy/lib/hamcrest-core-1.3.jar /home/codewarrior/Keypad.java /home/codewarrior/KeypadTest.java ./frameworks/java/CwRunListener.java
    [parsing started RegularFileObject[/home/codewarrior/Keypad.java]]
    [parsing completed 30ms]
    /home/codewarrior/KeypadTest.java:64: error: unmappable character for encoding ASCII
    assertEquals(1, Keypad.presses("A,!??$@:"));
    /home/codewarrior/KeypadTest.java:64: error: unmappable character for encoding ASCII
    assertEquals(1, Keypad.presses("A,!??$@:"));
    [parsing started RegularFileObject[/home/codewarrior/KeypadTest.java]]
    [parsing completed 14ms]
    [parsing started RegularFileObject[./frameworks/java/CwRunListener.java]]
    [parsing completed 2ms]
    [total 104ms]
    2 errors


    So it is impossible to submit a solution at this point.