Ad
  • Custom User Avatar

    I did the same and it was very fun ;)

  • Custom User Avatar

    Invalid punctuation has been removed from Java tests.

  • Custom User Avatar

    ahahaha that is thinking outside the box..

  • Default User Avatar
  • Default User Avatar

    Chess characters support added in python and java!!

    \o/

  • Custom User Avatar

    And for me..

  • Default User Avatar

    At least, we've tried :)

  • Default User Avatar

    Still not working... :(

  • 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

    But in the JS translation, that works... :o So?

  • Default User Avatar

    These days with UTF-8 it's basically print("ⓦⓗⓐⓣⓔⓥⓔⓡ") in any language. If it doesn't work, it's a bug feature on Codewars.

  • Default User Avatar

    Doesn't work... :/ Still got "?" in the board instead of the chess chars when I just copy/paste the symbols in the code. Surely I'm missing some tool to configure the thing correctly.

    The JS version handles the thing differently, using something like codepoints (I guess...?):

    var c = 0x2654;
    if(p.owner == 1)
      c += 6;
    switch(p.piece)
    {
      case "pawn": c++;
      case "knight": c++;
      case "bishop": c++;
      case "rook": c++;
      case "queen": c++;
    }
    return String.fromCharCode(c);
    

    If you know how to do the same in java, I'll try it too.

  • 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!

  • Default User Avatar

    Well... Could you provide the piece of code to use them as strings? Because with what I tried, I only get "?" in the board (I'm not confortable/used to unicode chars, especially in Java...)

  • Default User Avatar

    Hi,

    I confess I didn't try those being not sure if java could handle them, when I made the translation. I'll try that, thx.

  • Loading more items...