Join the discussion

Write your take first — we'll ask for email only when you're ready to publish.

  • Hacker News
  • Thanks for this OP. Really enjoyed finding solutions, and of course reading comments about all crazy looking solutions as well. This is the stuff that keeps me hooked to HN!

    I remember being given another puzzle in my childhood, where the task was to put 8 queens on the board and none of them should "see" each other. Wonder how many solutions exist for that one..

    ETA: Apparently it's a classic puzzle, and there are 92 solutions - https://en.wikipedia.org/wiki/Eight_queens_puzzle

  • I solved it with this, a pleasingly symmetric solution. I was surprised that a solution exists with all the queens in a row.

        . . . . . . . .
        . . . . . . . Q
        . . B . . . . .
        . . . . . Q . .
        . . . . . . . .
        . . . Q . . . .
        . . . . . . . .
        . Q . . . . . .
  • > In other words, after arranging the five black pieces, it must be impossible to place the white king anywhere without it being in checkmate.

    I think this is a bit ambiguous and, strictly speaking, wrong for the solution as given.

    In particular, this asks for the king to be in check _mate_. Does this require all black pieces to defend each other? Otherwise, white king on the board would not be in checkmate if you place it next to a queen and can immediately capture.

    From the solution, you can see it's not a checkmate requirement, just a check requirement.

  • Please don’t use red and green for the colors in the “check” mode, it’s hard to tell apart for colorblind people (especially against the partially shaded black squares).

    In fact, there isn’t really a need for two colors. Just color the squares that are threatened by the pieces and leave the rest blank. The meaning will be obvious.

  • Really nice but I wish I didn't have to click "Check" every time after moving the pieces. It could do that automatically.
  • The trick for me was to place a queen (most anywhere, but start with a corner it’s easier), then check and look for the spot with the most reds around it (eg 9, or 8, or 7), place the next queen there, repeat. Then place the bishop as needed.

    The key was realizing the proximal spaces next to the placed queen are the most important to cover. Forget about trying to have a long reach, it comes naturally.

  • > The task is to place four black queens and one black bishop on the chessboard so that there is no square not under their attack. In other words, after arranging the five black pieces, it must be impossible to place the white king anywhere without it being in checkmate.

    That last word should be "check". not "checkmate". A king next to an unprotected queen will be in check but not checkmate as it can capture the queen.

  • Neat. Surprisingly, there are 388 solutions, and a lot of them look rather unintuitive.

        ........
        ...Q....
        ........
        ........
        .....Q..
        ........
        ........
        Q..B..Q.
    
        Q.......
        ........
        ........
        ........
        ..QQB..Q
        ........
        ........
        ........
    
    My original intuition was to place the queens on unique rows and columns to cover as much as possible but it turns out there are solutions with three of them on the same row.

    Python script: https://gist.github.com/dllu/698d5f71b2b9735c5c462ddf4a2f6fc...

    Here's how it works:

    0. precompute the attack patterns of each possible queen/bishop location as a bitmask, stored as an integer

    1. generate candidate solutions, allowing attack rays to pass through other pieces, by brute forcing the positions of the 5 pieces and taking the bitwise OR of their attacks

    2. out of the candidate solutions, check which ones are actually valid taking into account occlusion. Actually, you only need to check if the queen's horizontal attack is blocked by the bishop, as queens cannot block each other (the blocking queen herself has the same attacks so they effectively pass through each other).

    by dllu

Explore Birbla archives