The Najdorf Variation of the Sicilian Defence is an opening often played at the highest level of chess. It is named after GM Miguel Najdorf and is known for being extremely sharp and theory heavy.

Your task is to write a program that, given a Boolean-like input, prints a chessboard representation of the opening from either White or Black perspective.

I/O format

Your program can take any input that has two possible values. Boolean, Integer, etc.

Your program must output a square chessboard using your language's standard output (usually the console). Each piece must have a corresponding character (your choice). Black and white pieces must be different. Black and white squares are allowed to be the same, but you are allowed to have different characters for them if you wish.

Using standard notation and uppercase for white and lowercase for black, here are the two chessboards, though you are free to represent the pieces differently:

True               False

R   B K Q B   R    r n b q k b   r
P P P     P P P      p     p p p p
          N        p     p   n    
      P N                         
                         N P      
    n   p     p        N          
p p p p     p      P P P     P P P
r   b k q b n r    R   B Q K B   R

This is , so shortest program in bytes wins!

  • \$\begingroup\$ Challenges should be as self-contained as possible. I've included the chessboard configurations themselves into the challenge so that the challenge contains the details, but also keeps the link to the Wikipedia page for further details. \$\endgroup\$
    – hyper-neutrino
    Commented Apr 30, 2021 at 4:47
  • 6
    \$\begingroup\$ Is the example correct? Shouldn't the opposite side see the board 180 degrees rotated instead of rows reversed? \$\endgroup\$
    – Bubbler
    Commented Apr 30, 2021 at 4:55
  • 2
    \$\begingroup\$ Also, it seems like the Black King's Knight is not at the right position in the True version. \$\endgroup\$
    – Arnauld
    Commented Apr 30, 2021 at 5:21
  • \$\begingroup\$ @Bubbler Fixed. \$\endgroup\$ Commented Apr 30, 2021 at 10:49
  • \$\begingroup\$ @Bubbler You're right; that's my bad. Sorry. \$\endgroup\$
    – hyper-neutrino
    Commented May 1, 2021 at 21:43

5 Answers 5


Jelly, 45 bytes


0 outputs from White's perspective, 1 from Black's.

As allowed in the question this uses other characters, the mapping is:

     Black  White
R      u      t
N      y      i
B      n      a
Q      p      b
K      r      l
P      d      c
empty  e      e

Try it online!
Or see this version which uses the letters from the question's example output and . for empty.


“...’ṃ“Œ⁼L»s8UṚ$¡G - Main Link: integer (from [0,1]), is_Black
“...’              - a large integer (stored in base 250)
      “Œ⁼L»        - dictionary word = "unpredictably"
     ṃ             - base-decompress (i.e. use "unpredictably" as the base-13 digits)
           s8      - split into slices eight long
                ¡  - repeat (is_Black) times:
               $   -   last two links as a monad:
             U     -     reverse each
              Ṛ    -     reverse
                       (equivalent to rotating a 1/2 turn)
                 G - format as a grid
  • \$\begingroup\$ Oh, using another character set like that is very clever :) \$\endgroup\$
    – hyper-neutrino
    Commented May 1, 2021 at 21:42

JavaScript (Node.js), 114 89 124 bytes

P  P N
ppp  ppp
r bqkb r`.split`

Try it online!

Take the grid and flip if needed.

  • \$\begingroup\$ You can save a byte by using f.sort(_=>x||-1) instead of (x?f:f.reverse()). But the 2nd row is only 7 characters long. I guess they should all be padded to 8 characters or not padded at all. \$\endgroup\$
    – Arnauld
    Commented Apr 30, 2021 at 5:32
  • \$\begingroup\$ (Since the sort is stable, f.sort(_=>x-1) should be fine as well.) \$\endgroup\$
    – Arnauld
    Commented Apr 30, 2021 at 6:05

Jelly, 64 bytes


Try it online!

-6 bytes thanks to Lyxal by compressing the string using Jelly's built-in dictionary compressed string type.


“...»       The grid itself
     UṚ$    Reverse the order of rows and rows themselves (180 degree rotation)
        ¡   N times
         G  Formatted as a grid
  • \$\begingroup\$ You mean string compression is useless here? \$\endgroup\$
    – lyxal
    Commented Apr 30, 2021 at 10:36
  • \$\begingroup\$ Your program must output a square chessboard using your language's standard output - I think the footer, which formats it into a grid, has to count towards the size of the program \$\endgroup\$ Commented Apr 30, 2021 at 10:49
  • \$\begingroup\$ @EnderShadow8 Fair enough. Outputting 2D text in native data types is usually accepted but since this is very similar to a kolmogorov challenge it's fair enough that I need to output the actual text and not just an internal representation. \$\endgroup\$
    – hyper-neutrino
    Commented Apr 30, 2021 at 17:09
  • \$\begingroup\$ @Lyxal I'm surprised, but despite there being next to no pattern to this, dictionary compression does actually shorten it. It might be due to all the spaces. \$\endgroup\$
    – hyper-neutrino
    Commented Apr 30, 2021 at 17:13

Vyxal j, 49 45 42 bytes


Try it Online!

»...»           # Push compressed integer
     k6         # Push constant `0123456789abcdef`
       3ȯ       # Slice from 3rd character (`3456789abcdef`)
         τ      # Custom base conversion (to base13 with above)
          ?ßṘ   # If input is truthy, reverse
             8/ # Divide into 8 pieces
                # Implicit join by newline
  • \$\begingroup\$ The shorter one is allowed by the rules stated. \$\endgroup\$ Commented May 21, 2021 at 12:09
  • \$\begingroup\$ @EnderShadow8 Ok. \$\endgroup\$
    – emanresu A
    Commented May 21, 2021 at 12:10

Charcoal, 46 bytes


Try it online! Link is to verbose version of code. Uses 0 for White's view and 4 for Black's view. Assumes that Black wants to see the board rotated rather than flipped. Explanation:


Print the compressed board.


Space the characters out horizontally.


Rotate the board as necessary.

42 bytes without the horizontal spacing:


Try it online! Link is to verbose version of code. Explanation: Prints the same compressed string, but in the input direction, which means that the string terminator is no longer required.

30 bytes by using a custom output format:


Try it online! Link is to verbose version of code. Uses the following key:

.   Black pawn
!   White pawn
"   Black rook
#   Black knight
$   Black bishop
%   White rook
&   White knight
'   White bishop
(   Black king
)   Black queen
*   White king
+   White queen
  • 1
    \$\begingroup\$ I think spacing out the characters isn't needed, althought the examples show it that way. \$\endgroup\$
    – Razetime
    Commented Apr 30, 2021 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.